Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library User's Guide

24.2 The C++ Locales

In C++, a locale is a class called locale provided by the C++ Standard Library. The C++ class locale differs from the C locale because it is more than a language table, or data representation of the various culture and language dependencies. It also includes the internationalization services, which in C are global functions.

In C++, internationalization semantics are broken out into separate classes called facets. Each facet handles a set of internationalization services; for example, the formatting of monetary values. Facets may also represent a set of culture and language dependencies, such as the rules and symbols for monetary information.

Each locale object maintains a set of facet objects. In fact, you can think of a C++ locale as a container of facets, as illustrated in Figure 5 below:

Figure 5: A C++ locale is a container of facets

24.2.1 Facets

Facet classes encapsulate data that represents a set of culture and language dependencies, and offer a set of related internationalization services. Facet classes are very flexible. They can contain just about any internationalization service you can invent. The C++ Standard Library offers a number of predefined standard facets, which provide services similar to those contained in the C library. However, you could bundle additional internationalization services into a new facet class, or purchase a facet library.

24.2.1.1 The Standard Facets

The C locale is composed of six categories of locale-dependent information: LC_NUMERIC (rules and symbols for numbers), LC_TIME (values for date and time information), LC_MONETARY (rules and symbols for monetary information), LC_CTYPE (character classification and conversion), LC_COLLATE (collation sequence), and LC_MESSAGES (formats and values of messages).

Similarly, there are six categories of standard facet classes. A detailed description of these facets is contained in the Apache C++ Standard Library Reference Guide, but a brief overview is given below. Note that an abbreviation like num_get<> means that num_get is a class template taking two template arguments, a character type, and an input iterator type. The categories of the standard facets are:

The names of the standard facets obey certain naming rules. The get facet classes, like num_get and time_get, handle parsing. The put facet classes handle formatting. The punct facet classes, like numpunct and moneypunct, represent rules and symbols.



Previous fileTop of DocumentContentsIndex pageNext file