On Wednesday, 15 December 2004, at 00:45:13 (+0100),
Andreas Volz wrote:

> I don't know how to handle this language problem. At first I used
> setlocale (LC_ALL, NULL); to get the current locale for help. This
> worked well on my and most other systems. But then someone reported
> me a problem that on his system this doesn't work. I expect a return
> of one locale like "[EMAIL PROTECTED]". But this person get this result:
> 
> LC_CTYPE=en_US;LC_NUMERIC=en_US;LC_TIME=en_US;LC_COLLATE=C;LC_MONETARY=
> en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=en_US;LC_ADDRESS=en_US;L
> C_TELEPHONE=en_US;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=en_US
> 
> After some time I found the reason: setlocale (LC_ALL, NULL); seems
> to return all values If not all locales have the same value. (see:
> LC_COLLATE=C, others=en_US). So I used only LC_MESSAGES to get the
> locale and avoid this problems. Do you think I should return to
> LC_MESSAGES and use LANG as fallback if LC_MESSAGES is empty?

First off, it's setlocale(LC_ALL, ""), not setlocale(LC_ALL, NULL). :)

Secondly, once you've done that, you cannot assume that the returned
locale string is any particular value.  From the man page:

RETURN VALUE
       A  successful  call to setlocale() returns an opaque string
       that corresponds to the locale set.

"Opaque" means "don't look at this thing." :)

Use nl_langinfo(CODESET) to get the character encoding being used.

Michael

-- 
Michael Jennings (a.k.a. KainX)  http://www.kainx.org/  <[EMAIL PROTECTED]>
n + 1, Inc., http://www.nplus1.net/       Author, Eterm (www.eterm.org)
-----------------------------------------------------------------------
 "The key to success?  Work hard, stay focused, and marry a Kennedy."
                                              -- Arnold Schwarzenegger


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to