After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 611687 - gconvert g_filename_to_uri doesn't do what the documentation says
gconvert g_filename_to_uri doesn't do what the documentation says
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: win32
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-03 10:56 UTC by Fernando Casanova
Modified: 2017-07-25 10:20 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Fernando Casanova 2010-03-03 10:56:48 UTC
Hi,

I stumbled across some strange behaviour when working with g_filename_to_uri on Windows.

According to the documentation, http://library.gnome.org/devel/glib/stable/glib-Character-Set-Conversion.html#g-filename-to-uri

filename :
	an absolute filename specified in the GLib file name encoding, which is the on-disk file name bytes on Unix, and UTF-8 on Windows

Now, by looking at the code, I can see that the function doing this stuff is g_filename_to_uri_utf8. g_filename_to_uri first converts filename from the locale to utf8 and then calls g_filename_to_uri_utf8.

If I call g_filename_to_uri with a utf8 encoded filename, this function returns a twice encoded string.

If I have for instance a "ë" in UTF-16, it is transformed into
0xC3 AB ("Ã" + "«") in order to be UTF-8 compliant. If I try to input C:\\ë into 
g_filename_to_uri, I get as a result this: file:///C:/%C3%83%C2%AB
which is basically wrong (it should be file:///C:/%C3%AB).

Can someone explain me this strange behaviour? Is it something expected or am I doing things wrong?

   Thanks,

      Regards,

        Fernando
Comment 1 Christoph Reiter (lazka) 2017-07-25 10:20:29 UTC
1) g_filename_to_uri is not used on Windows. There is/was some ifdeffery to replace it with g_filename_to_uri_utf8. It was used when glib used ANSI paths on Windows and up until bug 780634 it was exported for ABI compat. That locale code is now gone.

2) I can't reproduce the problem, I get "%C3%AB" using glib master.

Maybe there was a problem and it was fixed in the mean time...