escape_string


Description:

[ Version ( since = "2.16" ) ]
public static string escape_string (string unescaped, string? reserved_chars_allowed = null, bool allow_utf8 = true)

Example: Escape strings:

public static int main (string[] args) {
string ressource = "foo/my ressource.txt";

// Output: ``Escaped ressource: "foo%2Fmy%20ressource.txt"``
string fragment = Uri.escape_string (ressource);
print ("Escaped ressource: \"%s\"\n", fragment);

// Output: ``Escaped ressource: "foo/my%20ressource.txt"``
fragment = Uri.escape_string (ressource, "/");
print ("Escaped ressource: \"%s\"\n", fragment);

return 0;
}

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