[MPlayer-dev-eng] locale in GUI

Ingo Brückl ib at wupperonline.de
Mon Mar 11 11:00:07 CET 2013


Reimar Döffinger wrote on Mon, 11 Mar 2013 09:41:40 +0100:

> "Ingo Brückl" <ib at wupperonline.de> wrote:

>>Hans-Dieter Kosch wrote on Sun, 10 Mar 2013 23:19:04 +0100:
>>
>>> Ingo Brückl wrote:
>>>> Hans-Dieter Kosch wrote on Sun, 10 Mar 2013 21:49:17 +0100:
>>>>
>>>>> Ingo Brückl wrote:
>>>>>> Hans-Dieter Kosch wrote on Sun, 10 Mar 2013 20:24:29 +0100:
>>>>>>
>>>>>>> Ingo Brückl wrote:
>>>>>>>> Hans-Dieter Kosch wrote on Sun, 10 Mar 2013 19:24:37 +0100:
>>>>>>>>
>>>>>>>>> the function g_filename_to_utf8() used in the GUI
>>(fileselect.c,
>>>>>>>>> playlist.c) doesn't return a filename containing characters
>>outside the
>>>>>>>>> standard ASCII range.
>>>>>>>> Please elaborate. I didn't notice any problems so far.
>>>>>>>>
>>>>>>> Just try a filename with german Umlauts, g_filename_to_utf8()
>>returns NULL
>>>>>>> with conversion error.
>>>>>> If that were so, I would have done a really bad job.
>>>>>>
>>>>> Oh, sorry. I meant 'g_filename_from_utf8()', not
>>'g_filename_to_utf8()'.
>>>>> Seems, I've too much messed up during last time. Bad mistake... :-(
>>>>
>>>> No, that works as well.
>>>>
>>>> What is your locale? Are your filenames encoded in that locale? Does
>>GLib
>>>> know about your filename encoding (if not UTF-8)?
>>>>
>>> My locale is en_US.UTF-8, the filenames are encoded in that locale.
>>> My env vars:
>>> LANG=en_US.UTF-8
>>> G_FILENAME_ENCODING=@locale,UTF-8,ISO-8859-15,CP1252
>>> G_BROKEN_FILENAMES=1
>>
>>Drop the @locale from G_FILENAME_ENCODING.
>>
>>If your filenames are encoded in UTF-8 you don't need
>>G_FILENAME_ENCODING at
>>all - and neither G_BROKEN_FILENAMES.

> I don't know how easy it would be, but it would be possible to avoid
> this issue for our GUI by never using the _from_utf8 function but
> instead storing the original string alongside the utf8 encoded one.

This is basically what we are doing with the _utf8 functions.

GLib assumes that all filenames (and all other strings) are UTF-8 encoded. So
any file system GLib function passes the names UTF-8 in <-> UFT-8 out.

For those of us having non-UTF-8 filenames, there is G_FILENAME_ENCODING. If
it is set, GLib can convert appropriately - which is done by
g_filename_from_utf8() and g_filename_to_utf8() (functions that probably just
return their input on UTF-8 systems).

You might know that I'm running an old ISO-8859-1 system. I've set
G_FILENAME_ENCODING=ISO-8859-1 and everything's running just fine. Inside
GLib/GTK my filenames are UTF-8, outside they're ISO-8859-1.

Hans-Dieter's problem is his using @locale for G_FILENAME_ENCODING (or
G_BROKEN_FILENAMES=1, meaning the same). So he's telling that his filenames
aren't UTF-8 encoded, but rather in locale encoding. However, we avoid
setting a reasonable locale for reasons known.

In short: If you have UTF-8 encoding, don't set the GLib environment
variables - everything will work just fine. Without UTF-8 encoding,
explicitly tell GLib by G_FILENAME_ENCODING which encoding you are using.
Don't use @locale or G_BROKEN_FILENAMES.

Ingo


More information about the MPlayer-dev-eng mailing list