我试图学习不同的语言环境并处理unicode,所以我选择将所有字符串都设为UTF-8,但我决定运行以下代码,但由于某种原因,它引发了错误,我无法弄清楚为什么.到目前为止,已经尝试了所有语言环境,除了"C"之外没有其他方法可用..我尝试了在此处找到的语言环境列表: gcc.gnu/onlinedocs/libstdc++/manual/localization.html
I'm trying to learn different locales and handling unicode and I chose to make all my strings UTF-8 and I decided to run the following code but for some reason it throws an error and I cannot figure out why.. I tried every locale so far and none except "C" works.. I tried the list of locales found here: gcc.gnu/onlinedocs/libstdc++/manual/localization.html
及其示例:
#include <iostream> #include <string> int main() { std::locale::global(std::locale("en_US.UTF-8")); return 0; }结果:
抛出'std :: runtime_error'实例后调用terminate what():地区::方面:: _ S_create_c_地区名称无效
terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid
我在做什么错了?
我正在Windows 8上使用带有最新代码块的Mingw-Builds gcc/g ++ 4.8.1.语言设置为EN_US,有时我切换到EN_GB.
I'm using Mingw-Builds gcc/g++ 4.8.1 with the latest codeblocks on Windows 8. Language is set to EN_US and sometimes I switch to EN_GB.
推荐答案上周我遇到了同样的问题,我编写了一个程序来打印Windows OS下所有受支持的语言环境名称.
I ran into same problem last week, I wrote a program to print all supported locale names under Windows OS.
查看我的答案打印所有std :: locale名称(Windows)
您要查找的语言环境只是Windows下的"en-US".
Locale that you are looking for is just "en-US" under Windows.
更多推荐
std :: locale :: facet ::
发布评论