1 <section xmlns="http://docbook.org/ns/docbook" version="5.0"
2 xml:id="std.localization.locales.locale" xreflabel="Locale">
4 <info><title>locale</title>
6 <keyword>ISO C++</keyword>
7 <keyword>locale</keyword>
14 Describes the basic locale object, including nested
15 classes id, facet, and the reference-counted implementation object,
19 <section xml:id="locales.locale.req"><info><title>Requirements</title></info>
23 Class locale is non-templatized and has two distinct types nested
31 22.1.1.1.2 Class locale::facet
37 Facets actually implement locale functionality. For instance, a facet
38 called numpunct is the data object that can be used to query for the
39 thousands separator in the locale.
43 Literally, a facet is strictly defined:
49 Containing the following public data member:
52 <code>static locale::id id;</code>
58 Derived from another facet:
61 <code>class gnu_codecvt: public std::ctype<user-defined-type></code>
67 Of interest in this class are the memory management options explicitly
68 specified as an argument to facet's constructor. Each constructor of a
69 facet class takes a std::size_t __refs argument: if __refs == 0, the
70 facet is deleted when the locale containing it is destroyed. If __refs
71 == 1, the facet is not destroyed, even when it is no longer
79 22.1.1.1.3 - Class locale::id
85 Provides an index for looking up specific facets.
89 <section xml:id="locales.locale.design"><info><title>Design</title></info>
93 The major design challenge is fitting an object-orientated and
94 non-global locale design on top of POSIX and other relevant standards,
95 which include the Single Unix (nee X/Open.)
99 Because C and earlier versions of POSIX fall down so completely,
100 portability is an issue.
105 <section xml:id="locales.locale.impl"><info><title>Implementation</title></info>
108 <section xml:id="locale.impl.c"><info><title>Interacting with "C" locales</title></info>
114 <code>locale -a</code> displays available locales.
422 <code>`locale`</code> displays environmental variables that
423 impact how locale("") will be deduced.
438 LC_MEASUREMENT="en_US"
439 LC_IDENTIFICATION="en_US"
447 From Josuttis, p. 697-698, which says, that "there is only *one*
448 relation (of the C++ locale mechanism) to the C locale mechanism: the
449 global C locale is modified if a named C++ locale object is set as the
450 global locale" (emphasis Paolo), that is:
453 <programlisting>std::locale::global(std::locale(""));</programlisting>
455 <para>affects the C functions as if the following call was made:</para>
457 <programlisting>std::setlocale(LC_ALL, "");</programlisting>
460 On the other hand, there is *no* vice versa, that is, calling
461 setlocale has *no* whatsoever on the C++ locale mechanism, in
462 particular on the working of locale(""), which constructs the locale
463 object from the environment of the running program, that is, in
464 practice, the set of LC_ALL, LANG, etc. variable of the shell.
470 <section xml:id="locales.locale.future"><info><title>Future</title></info>
476 Locale initialization: at what point does _S_classic, _S_global
477 get initialized? Can named locales assume this initialization
478 has already taken place?
484 Document how named locales error check when filling data
485 members. I.e., a fr_FR locale that doesn't have
486 numpunct::truename(): does it use "true"? Or is it a blank
487 string? What's the convention?
493 Explain how locale aliasing happens. When does "de_DE" use "de"
494 information? What is the rule for locales composed of just an
495 ISO language code (say, "de") and locales with both an ISO
496 language code and ISO country code (say, "de_DE").
502 What should non-required facet instantiations do? If the
503 generic implementation is provided, then how to end-users
504 provide specializations?
510 <bibliography xml:id="locales.locale.biblio"><info><title>Bibliography</title></info>
517 <author><personname><surname>McGrath</surname><firstname>Roland</firstname></personname></author>
518 <author><personname><surname>Drepper</surname><firstname>Ulrich</firstname></personname></author>
524 Chapters 6 Character Set Handling and 7 Locales and
533 <author><personname><surname>Drepper</surname><firstname>Ulrich</firstname></personname></author>
542 ISO/IEC 14882:1998 Programming languages - C++
552 ISO/IEC 9899:1999 Programming languages - C
562 <link xmlns:xlink="http://www.w3.org/1999/xlink"
563 xlink:href="https://pubs.opengroup.org/onlinepubs/9699919799/">
564 System Interface Definitions, Issue 7 (IEEE Std. 1003.1-2008)
570 The Open Group/The Institute of Electrical and Electronics
578 The C++ Programming Language, Special Edition
580 <author><personname><surname>Stroustrup</surname><firstname>Bjarne</firstname></personname></author>
583 <holder>Addison Wesley, Inc.</holder>
585 <pagenums>Appendix D</pagenums>
595 Standard C++ IOStreams and Locales
598 Advanced Programmer's Guide and Reference
600 <author><personname><surname>Langer</surname><firstname>Angelika</firstname></personname></author>
601 <author><personname><surname>Kreft</surname><firstname>Klaus</firstname></personname></author>
604 <holder>Addison Wesley Longman, Inc.</holder>
608 Addison Wesley Longman