This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Locales


Hi,

I have the following code that is supposed to print the name of the native locale:

#include <locale>
#include <iostream>

int main(int argc, char **argv)
{
    std::locale test("");    
    std::cout << "Native Locale is: " << test.name() << std::endl;
    return 0;
}

The above code on Windows with Visual Studio 7 shows:

Native Locale is: English_United_Kingdom

or something very close to that. Using gcc on Windows (MinGW's g++) it shows:

Native Locale is: C

which is relatively sensible, but using gcc (g++) on Linux I get:

Native Locale is: LC_TYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C; LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C; LC_MEASUREMENT=C;LC_IDENTIFICATION=C

when what I expected was:

Native Locale is: en_GB.UTF-8

or something similar. Now, I could extract the native locale from the LC_TYPE variable, but I wondered:

1) Was the list of locale LC_ variables something you would have expected?
2) Is there something else I should be constructing the locale with to give the native locale on Linux?
3) Is it possible to get the correct native locale on Windows with gcc (rather than C - the same results if I build and run the program in MSYS or the Windows Command Prompt)? Any answer to question 2 may answer this, I guess.

Thanks for any help you can give.

Chris



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]