如何在MinGW中更改语言环境

时间:2018-12-08 10:28:00

标签: c++ windows-10 mingw

似乎只有“ C”语言环境正在与MinGW一起使用。我尝试了example found here,即使系统区域设置设置为加拿大,也没有添加逗号。

#include <iostream>
#include <locale>

int main()
{
    std::wcout << "User-preferred locale setting is " << std::locale("").name().c_str() << '\n';
    // on startup, the global locale is the "C" locale
    std::wcout << 1000.01 << '\n';
    // replace the C++ global locale as well as the C locale with the user-preferred locale
    std::locale::global(std::locale(""));
    // use the new global locale for future wide character output
    std::wcout.imbue(std::locale());
    // output the same number again
    std::wcout << 1000.01 << '\n';
}

输出为

User-preferred locale setting is C
100000
100000

我尝试了std::locale("en-CA")并在运行时获得了locale::facet::_S_create_c_locale name not valid。我使用g ++从CMD编译。我正在运行64位Windows 10。

我也尝试编译此处接受的答案中的程序,并得到编译器错误'LOCALE_ALL' was not declared in this scope

如何将MinGW中的语言环境设置为系统默认值或显式设置?

0 个答案:

没有答案