什么std :: locale名称可用在常见的Windows编译器? [英] What std::locale names are available on common windows compilers?

查看:131
本文介绍了什么std :: locale名称可用在常见的Windows编译器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标准对于什么构成有效的区域设置名称非常隐晦;只有通过无效的区域设置名称会导致 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.com/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"
            | ""
            | NULL

This page provides links to :


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编译器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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