[MPlayer-dev-eng] locale in GUI

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Mar 11 08:48:34 CET 2013


On 11 Mar 2013, at 08:23, Dan Oscarsson <Dan.Oscarsson at tieto.com> wrote:
> sön 2013-03-10 klockan 20:32 +0100 skrev Reimar Döffinger:
> 
>>>>> This is because setting the locale is disabled by gtk_disable_setlocale()
>>>>> in gui/dialog/dialog.c (r22126) and thus glib works on the "C" locale. Does
>>>>> anybody remember the reason?
>>>> See
>>>> http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2010-December/067107.html
>>> I suspected such adversity...
>>> 
>>> What about that:
>>> 
>>> old_locale = setlocale(LC_ALL, NULL);
>>> setlocale(LC_ALL, "");
>>> g_filename_to_utf8(...);
>>> setlocale(LC_ALL, old_locale);
>>> 
>>> Bad hack, admittedly.
>> 
>> No, broken. setlocale affects all threads. It might result in for
>> example HTTP requests made by the cache (if run in thread instead of
>> separate process) randomly generating wrong requests.
>> A debugging nightmare.
> 
> I assume this problem is due to bad programming. Parsers should not be
> dependent on locale if they expect, for example, real numbers to have a
> decimal point. In a GUI local preferences should be used - this includes
> displaying numbers using the decimal separator of current locale and
> dates as specified by current locale.

Yes, unfortunately the bad programmers were the libc developers.
Or do you seriously suggest that we reimplement all relevant libc functions, scanf, sscanf, fscanf, printf, atof, atoi, strtoll, toupper, tolower and a whole bunch more?
Not even FFmpeg does that and thus will be broken for some locales.
Not to mention that designing an option syntax that works reasonably for all possible decimal separators is not reasonable, so the GUI still can't use the locale.
At least we're not as bad as Excel, which just fails to open .csv files if comma is the locales' decimal separator with no way to fix it besides manually editing the csv...


More information about the MPlayer-dev-eng mailing list