[MPlayer-dev-eng] locale in GUI

Ingo Brückl ib at wupperonline.de
Tue Mar 12 16:39:56 CET 2013


Hans-Dieter Kosch wrote on Mon, 11 Mar 2013 23:30:11 +0100:

> Reimar Döffinger wrote:
> [...]
>>>> 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.
>>
>> The point of my suggestion is to make it work without such arbitrary rules.
>> The from_utf8 function cannot work on a system that mixes utf8 and Latin1 file names, while the to_utf8 can work just fine. Thus avoiding the former (which for us should not be a big problem) makes the code more robust.
>>
> Maybe I have a basic idea for a patch; need to think a few days...

I actually don't think that a patch is necessary, because it works as
designed by the GLib developers. (And, btw, the rules aren't arbitrary. The
only confusion comes with us not setting the locale which, on the other hand,
isn't a problem at all.)

If we don't properly translate the filenames between file system and GLib,
we'll run into trouble with either the display or use of them.

Ingo


More information about the MPlayer-dev-eng mailing list