| Boost.Locale

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Examples

Getting information about the current locale

The `std::locale::name` function provides very limited information about a locale. Such a name is platform- and compiler-dependent, and is useless for Boost.Locale. There is no way to change it, so for all locales created by Boost.Locale, `name()` returns the same value as `name()` for `std::locale::classic()`.

Thus an additional facet was created, giving more precise information: boost::locale::info. It has the following member functions:

- std::string name() -- the full name of the locale, for example `en_US.UTF-8`
- std::string language() -- the ISO-639 language code of the current locale, for example "en".
- std::string country() -- the ISO-3199 country code of the current locale, for example "US".
- std::string variant() -- the variant of current locale, for example "euro".
- std::string encoding() -- the encoding used for `char` based strings, for example "UTF-8"
- bool utf8() -- a fast way to check whether the encoding is UTF-8.

For example:

        cout << "The language code is " << std::use_facet<boost::locale::info>(some_locale).language() << endl;