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
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 callingsetlocale(LC_ALL, loc.name.c_str)
.
Also see this page and this thread which tend to show that std::locale
internally uses setlocale
.