libcurl has an easy implementation which would encode the path strings
curl_easy_escape curl_easy_unescape
There are other implementations in "wget" project which can be ported to gnu pdf.
glib project has "g_uri_escape_string" but it seemed to me more like RFC3986 implementation, which doesn't involve escaping "<scheme>:<scheme-resource>" .
Let me know if this dependency to libcurl is acceptable to gnupdf project ? .