[MPlayer-dev-eng] [PATCH] Use _NET_WM_NAME for UTF-8 title in X11 if supported

Sergey Pinaev dfo at antex.ru
Wed Jun 21 08:34:40 CEST 2006


On Wed, 21 Jun 2006 01:53:57 -0400
Rich Felker <dalias at aerifal.cx> wrote:

> > > setlocale is forbidden (with the mp_msg.c exception).
> > 
> > Even for LC_CTYPE? Why? It's affects only things like isalpha(),
> > islower(), tolower/toupper.
> 
> toupper/tolower is not the worst problem, but still bad. Calling
> setlocale causes them to be broken in the Turkish locale. This is
> known to prevent certain code from working due to i/I mapping to
> non-ASCII characters. It actually caused MPlayer to crash in the past,
> IIRC.

afaiu this is not "locale" problem, but just mistake of man, who
write locale definition file for Turkish.
(Keld.Simonsen at dkuug.dk according to /usr/share/i18n/locales/tr_TR)

> Blame C for stupidly linking the concept of codeset to language and
> case rules...
> 
> The worst problem, for anyone interested, is LC_NUMERIC. Replacing .
> with , causes all sorts of nightmares for parsing and writing data
> files. Aside from tutorial programs in textbooks, the printf and scanf
> family of functions are used mostly for reading and writing data files
> which must have the same format regardless of locale. This is
> certainly a more important use than printing messages to the user or
> receiving input from the user in the user's own cultural conventions.

I didnt get your point. Thats exactly why LC_NUMERIC exist. If you want
"same format regardless of locale" - you call setlocale(LC_NUMERIC, "C");
If you want "printing messages in the user's own cultural conventions" -
you call setlocale(LC_NUMERIC, ""). (And user that does not like "," in
place of "." just sets LC_NUMERIC to "C" in his shell profile =/)

> P.S. It would have been incredibly easy for C to add a flag to the
> printf format specifiers to indicate whether to use a localized format
> or the "C locale" format when printing numbers, but instead they chose
> the incredibly broken and stupid way, making locale essentially
> useless in practice...

char *saved = setlocale(LC_NUMERIC, "C");
printf("%f\n", blah);
setlocale(LC_NUMERIC, saved);

Yes, in this simple case this can look "bloat". But when code between
setlocale's is more complex and have more %'s it is simpler/cleaner
than "locale modifiers" appended to each %, imho.

-- 
mail="Sergey Pinaev <dfo at antex.ru>"
url="http://`echo $mail | sed 's/.* <\(.*\)@\(.*\)>/\1.\2/'`"



More information about the MPlayer-dev-eng mailing list