1 <section id="std.localization.locales.locale" xreflabel="Locale">
17 Describes the basic locale object, including nested
18 classes id, facet, and the reference-counted implementation object,
22 <section id="locales.locale.req">
23 <title>Requirements</title>
26 Class locale is non-templatized and has two distinct types nested
34 22.1.1.1.2 Class locale::facet
40 Facets actually implement locale functionality. For instance, a facet
41 called numpunct is the data object that can be used to query for the
42 thousands separator in the locale.
46 Literally, a facet is strictly defined:
52 Containing the following public data member:
55 <code>static locale::id id;</code>
61 Derived from another facet:
64 <code>class gnu_codecvt: public std::ctype<user-defined-type></code>
70 Of interest in this class are the memory management options explicitly
71 specified as an argument to facet's constructor. Each constructor of a
72 facet class takes a std::size_t __refs argument: if __refs == 0, the
73 facet is deleted when the locale containing it is destroyed. If __refs
74 == 1, the facet is not destroyed, even when it is no longer
82 22.1.1.1.3 - Class locale::id
88 Provides an index for looking up specific facets.
92 <section id="locales.locale.design">
96 The major design challenge is fitting an object-orientated and
97 non-global locale design on top of POSIX and other relevant standards,
98 which include the Single Unix (nee X/Open.)
102 Because C and earlier versions of POSIX fall down so completely,
103 portability is an issue.
108 <section id="locales.locale.impl">
109 <title>Implementation</title>
111 <section id="locale.impl.c">
112 <title>Interacting with "C" locales</title>
117 <code>`locale -a`</code> displays available locales.
425 <code>`locale`</code> displays environmental variables that
426 impact how locale("") will be deduced.
441 LC_MEASUREMENT="en_US"
442 LC_IDENTIFICATION="en_US"
450 From Josuttis, p. 697-698, which says, that "there is only *one*
451 relation (of the C++ locale mechanism) to the C locale mechanism: the
452 global C locale is modified if a named C++ locale object is set as the
453 global locale" (emphasis Paolo), that is:
456 <programlisting>std::locale::global(std::locale(""));</programlisting>
458 <para>affects the C functions as if the following call was made:</para>
460 <programlisting>std::setlocale(LC_ALL, "");</programlisting>
463 On the other hand, there is *no* vice versa, that is, calling
464 setlocale has *no* whatsoever on the C++ locale mechanism, in
465 particular on the working of locale(""), which constructs the locale
466 object from the environment of the running program, that is, in
467 practice, the set of LC_ALL, LANG, etc. variable of the shell.
473 <section id="locales.locale.future">
474 <title>Future</title>
479 Locale initialization: at what point does _S_classic, _S_global
480 get initialized? Can named locales assume this initialization
481 has already taken place?
487 Document how named locales error check when filling data
488 members. I.e., a fr_FR locale that doesn't have
489 numpunct::truename(): does it use "true"? Or is it a blank
490 string? What's the convention?
496 Explain how locale aliasing happens. When does "de_DE" use "de"
497 information? What is the rule for locales composed of just an
498 ISO language code (say, "de") and locales with both an ISO
499 language code and ISO country code (say, "de_DE").
505 What should non-required facet instantiations do? If the
506 generic implementation is provided, then how to end-users
507 provide specializations?
513 <bibliography id="locales.locale.biblio">
514 <title>Bibliography</title>
521 <surname>McGrath</surname>
522 <firstname>Roland</firstname>
525 <surname>Drepper</surname>
526 <firstname>Ulrich</firstname>
533 Chapters 6 Character Set Handling and 7 Locales and
543 <surname>Drepper</surname>
544 <firstname>Ulrich</firstname>
554 ISO/IEC 14882:1998 Programming languages - C++
564 ISO/IEC 9899:1999 Programming languages - C
573 <biblioid class="uri">
574 <ulink url="http://www.opengroup.org/austin">
576 System Interface Definitions, Issue 7 (IEEE Std. 1003.1-2008)
583 The Open Group/The Institute of Electrical and Electronics
591 The C++ Programming Language, Special Edition
594 <surname>Stroustrup</surname>
595 <firstname>Bjarne</firstname>
599 <holder>Addison Wesley, Inc.</holder>
601 <pagenums>Appendix D</pagenums>
611 Standard C++ IOStreams and Locales
614 Advanced Programmer's Guide and Reference
617 <surname>Langer</surname>
618 <firstname>Angelika</firstname>
621 <surname>Kreft</surname>
622 <firstname>Klaus</firstname>
626 <holder>Addison Wesley Longman, Inc.</holder>
630 Addison Wesley Longman