什么std :: locale名称可用在常见的Windows编译器?

编程入门 行业动态 更新时间:2024-10-09 19:15:55
本文介绍了什么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/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 :

  • 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编译器?

本文发布于:2023-11-24 16:57:02,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:编译器   用在   常见   名称   std

发布评论

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

>www.elefans.com

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