What std::locale names are available on common windows compilers?

后端 未结 3 715
我在风中等你
我在风中等你 2020-11-30 03:22

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

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 03:59

    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.

提交回复
热议问题