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

See:




2022 vala-language.org