nor*_*ner 5 c++ mingw windows-10
似乎只有“C”语言环境可以与 MinGW 配合使用。我尝试了此处找到的示例,即使系统区域设置设置为加拿大,也没有添加逗号。
#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';
}
Run Code Online (Sandbox Code Playgroud)
输出是
User-preferred locale setting is C
100000
100000
Run Code Online (Sandbox Code Playgroud)
我尝试在运行时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 中的区域设置设置为系统默认值或显式设置?