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位Windows10。
此外,我试图编译这个程序中发现的接受答案在这里,并得到编译器错误
'LOCALE_ALL' was not declared in this scope
.