C++ Locale Names in MinGW
With Visual C I can set a locale like this:
locale::global(locale("chi nese-simpl ified"));
With Linux I can set a locale like this:
locale::global(locale("zh_ CN.utf8")) ;
I have tried these names and a lot of others with MinGW, but nothing works. What does MinGW use for locale names? An example doesn’t have to be Chinese, it can be any language. Is there a list somewhere?
Thanks
locale::global(locale("chi
With Linux I can set a locale like this:
locale::global(locale("zh_
I have tried these names and a lot of others with MinGW, but nothing works. What does MinGW use for locale names? An example doesn’t have to be Chinese, it can be any language. Is there a list somewhere?
Thanks
>> I have tried these names and a lot of others with MinGW, but nothing works.
A locale will only work if it is installed on your system. If my mind serves me well, the C++ style std::locale in MinGW will not work, unless the proper locales are somehow defined in MinGW (which is not likely).
At the very least, the "C" locale should work. Try that, just to verify that the locale functionality is working the way you use it :
locale::global(locale("C") );
That won't resolve your issue, but try using setlocale instead :
setlocale(LC_ALL, "your_locale");
it should make use of the Windows C runtime, so if it works under Visual C, it should work under MinGW.
A locale will only work if it is installed on your system. If my mind serves me well, the C++ style std::locale in MinGW will not work, unless the proper locales are somehow defined in MinGW (which is not likely).
At the very least, the "C" locale should work. Try that, just to verify that the locale functionality is working the way you use it :
locale::global(locale("C")
That won't resolve your issue, but try using setlocale instead :
setlocale(LC_ALL, "your_locale");
it should make use of the Windows C runtime, so if it works under Visual C, it should work under MinGW.
The C locale functions do work on MinGW. They use the same names as Visual Studio. The C++ functions do NOT work.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
That's not what I wanted to hear, but I think you're right. MinGW even gets an error when loading the native locale. The problem with C locales is you can't imbue the cout streams. I am going to have to rethink what I am trying to do.
Thanks for the comments.
Thanks for the comments.
Comments added to thread.