标准对于什么构成有效的区域设置名称非常隐晦;只有通过无效的区域设置名称会导致 std :: runtime_error 。
解决方案我相信你需要的信息是此处:
localelang [_country_region [.code_page]] | .code_page | | NULL此页面提供以下链接:
- 语言字符串
- 国家/地区字符串
- 代码页
虽然我的答案涵盖 setlocale 而不是 std :: locale 此MSDN页面似乎意味着该格式确实是相同:
类别locale的对象还将a语言环境名称存储为类别的对象。使用无效的区域设置名称构造语言环境构面或语言环境对象引发类 runtime_error 的对象。如果语言环境对象不能确定 C风格的语言环境与该对象所表示的完全对应,那么存储的语言环境名称为*。 否则,你可以在标准C 库中为locale对象loc建立一个匹配的语言环境,通过调用 setlocale(LC_ALL,$ b $ ://connect.microsoft/VisualStudio/feedback/details/492128/std-locale-constructor-modifies-global-locale-via-setlocale>此页和这个线程,倾向于显示 std :: locale code>内部使用 setlocale 。
The standard is pretty much silent on what constitutes a valid locale name; only that passing an invalid locale name results in std::runtime_error. What locale names are usable on common windows compilers such as MSVC, MinGW, and ICC?
解决方案I believe the information you need is here :
locale "lang[_country_region[.code_page]]" | ".code_page" | "" | NULLThis page provides links to :
- Language Strings
- Country/Region String
- Code Pages
Although my answers covers setlocale instead of std::locale, this MSDN page seems to imply that the format is indeed the same :
An object of class locale also stores a locale name as an object of class string. Using an invalid locale name to construct a locale facet or a locale object throws an object of class runtime_error. The stored locale name is "*" if the locale object cannot be certain that a C-style locale corresponds exactly to that represented by the object. Otherwise, you can establish a matching locale within the Standard C Library, for the locale object loc, by calling setlocale(LC_ALL, loc.name.c_str).
Also see this page and this thread which tend to show that std::locale internally uses setlocale.
更多推荐
什么std :: locale名称可用在常见的Windows编译器?
发布评论