How to URL encode (percent encode) a string in Vala (GLib):
Uri.escape_string ("Hello, world!");
// Hello%2C%20world%21
To decode:
Uri.unescape_string ("Hello%2C%20world%21");
// Hello, World!
(Documenting it as it was not easy to find with a cursory web search.)