unescape_string


Description:

[ Version ( since = "2.16" ) ]
public static string? unescape_string (string escaped_string, string? illegal_characters = null)

Unescapes a whole escaped string.

If any of the characters in illegal_characters or the NUL character appears as an escaped character in escaped_string , then that is an error and null will be returned. This is useful if you want to avoid for instance having a slash being expanded in an escaped path element, which might confuse pathname handling.

Example: Unescape strings:

public static int main (string[] args) {
string escaped1 = "foo%2Fmy%20ressource.txt";
string escaped2 = "foo/my%20ressource.txt";


// Output: ``Unescaped: "(null)"``
string fragment = Uri.unescape_string (escaped1, "/");
print ("Unescaped: \"%s\"\n", fragment);

// Output: ``Unescaped: "foo/my ressource.txt"``
fragment = Uri.unescape_string (escaped1);
print ("Unescaped: \"%s\"\n", fragment);

// Output: ``Unescaped: "foo/my ressource.txt"``
fragment = Uri.unescape_string (escaped2);
print ("Unescaped: \"%s\"\n", fragment);

return 0;
}

valac --pkg glib-2.0 GLib.Uri.unescape_string.vala

Parameters:

escaped_string

an escaped string to be unescaped.

illegal_characters

a string of illegal characters not to be allowed, or null.

Returns:

an unescaped version of escaped_string. The returned string should be freed when no longer needed.