常见的Windows编译器提供哪些std :: locale名称?
收藏

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?

最佳答案

我相信您需要的信息在这里:

locale  "lang[_country_region[.code_page]]"
            | ".code_page"
            | ""
            | NULL

此页面提供指向以下内容的链接:

  • 语言字符串
  • 国家/地区字符串
  • 代码页

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.

    公众号
    关注公众号订阅更多技术干货!