std :: locale :: facet :: _ S_create_c_locale名称无效 [英] std::locale::facet::_S_create_c_locale name not valid

查看:82
本文介绍了std :: locale :: facet :: _ S_create_c_locale名称无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图学习不同的语言环境并处理unicode,所以我选择将所有字符串都设为UTF-8,但我决定运行以下代码,但由于某种原因,它引发了错误,我无法弄清楚为什么.到目前为止,已经尝试了所有语言环境,除了"C"之外没有其他方法可用..我尝试了在此处找到的语言环境列表: http://gcc.gnu.org/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: http://gcc.gnu.org/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 :: _ S_create_c_locale名称无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆