std :: locale :: facet ::

编程入门 行业动态 更新时间:2024-10-09 01:24:57
本文介绍了std :: locale :: facet :: _ S_create_c_locale名称无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图学习不同的语言环境并处理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 ::

本文发布于:2023-11-24 16:53:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:std   locale   facet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!