Localization library
A locale is a set of features that are culture-specific, which can be used by programs to be more portable internationally.

In C++, locales are represented by an object of the locale class. Each of these locale objects contains all the information needed to use a set of culture-dependent features. But locale objects do not contain the features directly themselves as member functions: instead, a locale object contains information about which facet objects it selects, and is each one of these facet objects that implements specific features as member functions. This allows for features that are common to several locales to be shared by using the same facet objects, and makes them extensible, allowing custom facets to be added to locale objects.

Facets are divided into six standard categories:

categoryfacetmember functions
collatecollatecompare, hash, transform
ctypectypeis, narrow, scan_is, scan_not, tolower, toupper, widen
codecvtalways_noconv, encoding, in, length, max_length, out, unshift
monetarymoneypunctcurr_symbol, decimal_point, frac_digits, grouping, negative_sign, neg_format, positive_sign, pos_format, thousands_sep
numericnumpunctdecimal_point, falsename, grouping, thousands_sep, truename
timetime_getdate_order, get_date, get_monthname, get_time, get_weekday, get_year (and get, since C++11)
messagesmessagesclose, get, open

Locale objects can be constructed entirely from a name, taking all the characteristics of that named locale, or they can mix facet categories of different locales (see class locale constructor for more info).

Thus, the core of the localization functionality in C++ is implemented in the different facets. Facets are objects. These objects are managed automatically by the locale engine, therefore facet objects are generally neither constructed nor copied locally in a program (in fact a program is prevented to do so by their protected destructors). The most general way of accessing a particular feature of a facet associated with a locale is with the function use_facet:

// using facet member directly:
myvar = use_facet < numpunct<char> > (mylocale).decimal_point();

// alias facet:
const numpunct<char>& myfacet = use_facet < numpunct<char> > (mylocale);
myvar = myfacet.decimal_point();

Every facet:
  • is derived from class locale::facet (or from any class derived from it, like another facet).
  • define a static member called id of type locale::id with a specific value.
A program may define its own facets to be added to a locale by fulfilling the above requirements.

All facet constructors include as second parameter (called refs in this reference) that defines whether the class deallocation is delegated to the locale engine, and hence it is automatically deleted when the last locale object where it is present is destroyed, or whether the program is in charge of its deletion at some point.

Some facet have an equivalent but ending with "_byname". These facet types are used by the localization engine to construct the appropriate facet objects when a named locale object is constructed.

All the standard facets are designed with public members that call virtual protected members with the same name, but preceded with "do_". The implementation of the operation itself lies in the virtual protected member function (so that derived class can easily overwrite it), while the non-virtual public function may implement platform-specific functionality not related to the operation itself, but necessary to allow the feature to work properly on the system.

All library implementations provide at least all the facets by default for the char and wchar_t types as template parameters for the facet's character type.
All library implementations provide at least all the facets by default for the char and wchar_t types as template parameters for the facet's character type. Additionally, the codecvt facet is also required to support char16_t and char32_t.


Facet management:

Convenience interfaces (template versions of the cctype functions):


Standard facets:

Base classes for standard facets (defining member types):
<blockquote id="pwjBlLZ"><tr id="pwjBlLZ"></tr></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect><blockquote id="pwjBlLZ"><option id="pwjBlLZ"></option></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"></option></delect>
<delect id="pwjBlLZ"><option id="pwjBlLZ"></option></delect>
<delect id="pwjBlLZ"></delect>
<mark id="pwjBlLZ"></mark>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
<nav id="pwjBlLZ"><tr id="pwjBlLZ"><address id="pwjBlLZ"></address></tr></nav>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"></delect>
<mark id="pwjBlLZ"><tr id="pwjBlLZ"></tr></mark>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<blockquote id="pwjBlLZ"></blockquote>
<delect id="pwjBlLZ"><option id="pwjBlLZ"><blockquote id="pwjBlLZ"></blockquote></option></delect>
<blockquote id="pwjBlLZ"><option id="pwjBlLZ"></option></blockquote>
<delect id="pwjBlLZ"></delect>
<delect id="pwjBlLZ"></delect>
  • 629832435 2018-04-20
  • 4254782434 2018-04-20
  • 7642392433 2018-04-20
  • 4201592432 2018-04-20
  • 1221362431 2018-04-20
  • 5455692430 2018-04-20
  • 8345962429 2018-04-20
  • 7297372428 2018-04-20
  • 4929522427 2018-04-20
  • 1938132426 2018-04-20
  • 2267862425 2018-04-20
  • 6177082424 2018-04-20
  • 838232423 2018-04-20
  • 4694502422 2018-04-20
  • 6512882421 2018-04-19
  • 4659652420 2018-04-19
  • 2967832419 2018-04-19
  • 8339042418 2018-04-19
  • 8147112417 2018-04-19
  • 2774752416 2018-04-19