Link to home
Create AccountLog in
Avatar of jpattee
jpattee🇺🇸

asked on

C++ Locale Names in MinGW
With Visual C I can set a locale like this:
locale::global(locale("chinese-simplified"));

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
Avatar of Infinity08
Infinity08🇧🇪
>> 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.
Avatar of jpattee
jpattee🇺🇸

ASKER

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
Avatar of Infinity08
Infinity08🇧🇪
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jpattee
jpattee🇺🇸

ASKER

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.
Avatar of jpattee
jpattee🇺🇸

ASKER

Comments added to thread.