1<section xmlns="http://docbook.org/ns/docbook" version="5.0"
2	 xml:id="std.localization.locales.locale" xreflabel="Locale">
3
4<info><title>locale</title>
5  <keywordset>
6    <keyword>ISO C++</keyword>
7    <keyword>locale</keyword>
8  </keywordset>
9</info>
10
11
12
13<para>
14Describes the basic locale object, including nested
15classes id, facet, and the reference-counted implementation object,
16class _Impl.
17</para>
18
19<section xml:id="locales.locale.req"><info><title>Requirements</title></info>
20
21
22<para>
23Class locale is non-templatized and has two distinct types nested
24inside of it:
25</para>
26
27<blockquote>
28<para>
29<emphasis>
30class facet
3122.1.1.1.2 Class locale::facet
32</emphasis>
33</para>
34</blockquote>
35
36<para>
37Facets actually implement locale functionality. For instance, a facet
38called numpunct is the data object that can be used to query for the
39thousands separator in the locale.
40</para>
41
42<para>
43Literally, a facet is strictly defined:
44</para>
45
46<itemizedlist>
47  <listitem>
48    <para>
49      Containing the following public data member:
50    </para>
51    <para>
52      <code>static locale::id id;</code>
53    </para>
54  </listitem>
55
56  <listitem>
57    <para>
58      Derived from another facet:
59    </para>
60    <para>
61      <code>class gnu_codecvt: public std::ctype&lt;user-defined-type&gt;</code>
62    </para>
63  </listitem>
64</itemizedlist>
65
66<para>
67Of interest in this class are the memory management options explicitly
68specified as an argument to facet's constructor. Each constructor of a
69facet class takes a std::size_t __refs argument: if __refs == 0, the
70facet is deleted when the locale containing it is destroyed. If __refs
71== 1, the facet is not destroyed, even when it is no longer
72referenced.
73</para>
74
75<blockquote>
76<para>
77<emphasis>
78class id
7922.1.1.1.3 - Class locale::id
80</emphasis>
81</para>
82</blockquote>
83
84<para>
85Provides an index for looking up specific facets.
86</para>
87</section>
88
89<section xml:id="locales.locale.design"><info><title>Design</title></info>
90
91
92<para>
93The major design challenge is fitting an object-orientated and
94non-global locale design on top of POSIX and other relevant standards,
95which include the Single Unix (nee X/Open.)
96</para>
97
98<para>
99Because C and earlier versions of POSIX fall down so completely,
100portability is an issue.
101</para>
102
103</section>
104
105<section xml:id="locales.locale.impl"><info><title>Implementation</title></info>
106
107
108  <section xml:id="locale.impl.c"><info><title>Interacting with "C" locales</title></info>
109
110
111<itemizedlist>
112   <listitem>
113     <para>
114       <code>locale -a</code> displays available locales.
115     </para>
116<blockquote>
117<programlisting>
118af_ZA
119ar_AE
120ar_AE.utf8
121ar_BH
122ar_BH.utf8
123ar_DZ
124ar_DZ.utf8
125ar_EG
126ar_EG.utf8
127ar_IN
128ar_IQ
129ar_IQ.utf8
130ar_JO
131ar_JO.utf8
132ar_KW
133ar_KW.utf8
134ar_LB
135ar_LB.utf8
136ar_LY
137ar_LY.utf8
138ar_MA
139ar_MA.utf8
140ar_OM
141ar_OM.utf8
142ar_QA
143ar_QA.utf8
144ar_SA
145ar_SA.utf8
146ar_SD
147ar_SD.utf8
148ar_SY
149ar_SY.utf8
150ar_TN
151ar_TN.utf8
152ar_YE
153ar_YE.utf8
154be_BY
155be_BY.utf8
156bg_BG
157bg_BG.utf8
158br_FR
159bs_BA
160C
161ca_ES
162ca_ES@euro
163ca_ES.utf8
164ca_ES.utf8@euro
165cs_CZ
166cs_CZ.utf8
167cy_GB
168da_DK
169da_DK.iso885915
170da_DK.utf8
171de_AT
172de_AT@euro
173de_AT.utf8
174de_AT.utf8@euro
175de_BE
176de_BE@euro
177de_BE.utf8
178de_BE.utf8@euro
179de_CH
180de_CH.utf8
181de_DE
182de_DE@euro
183de_DE.utf8
184de_DE.utf8@euro
185de_LU
186de_LU@euro
187de_LU.utf8
188de_LU.utf8@euro
189el_GR
190el_GR.utf8
191en_AU
192en_AU.utf8
193en_BW
194en_BW.utf8
195en_CA
196en_CA.utf8
197en_DK
198en_DK.utf8
199en_GB
200en_GB.iso885915
201en_GB.utf8
202en_HK
203en_HK.utf8
204en_IE
205en_IE@euro
206en_IE.utf8
207en_IE.utf8@euro
208en_IN
209en_NZ
210en_NZ.utf8
211en_PH
212en_PH.utf8
213en_SG
214en_SG.utf8
215en_US
216en_US.iso885915
217en_US.utf8
218en_ZA
219en_ZA.utf8
220en_ZW
221en_ZW.utf8
222es_AR
223es_AR.utf8
224es_BO
225es_BO.utf8
226es_CL
227es_CL.utf8
228es_CO
229es_CO.utf8
230es_CR
231es_CR.utf8
232es_DO
233es_DO.utf8
234es_EC
235es_EC.utf8
236es_ES
237es_ES@euro
238es_ES.utf8
239es_ES.utf8@euro
240es_GT
241es_GT.utf8
242es_HN
243es_HN.utf8
244es_MX
245es_MX.utf8
246es_NI
247es_NI.utf8
248es_PA
249es_PA.utf8
250es_PE
251es_PE.utf8
252es_PR
253es_PR.utf8
254es_PY
255es_PY.utf8
256es_SV
257es_SV.utf8
258es_US
259es_US.utf8
260es_UY
261es_UY.utf8
262es_VE
263es_VE.utf8
264et_EE
265et_EE.utf8
266eu_ES
267eu_ES@euro
268eu_ES.utf8
269eu_ES.utf8@euro
270fa_IR
271fi_FI
272fi_FI@euro
273fi_FI.utf8
274fi_FI.utf8@euro
275fo_FO
276fo_FO.utf8
277fr_BE
278fr_BE@euro
279fr_BE.utf8
280fr_BE.utf8@euro
281fr_CA
282fr_CA.utf8
283fr_CH
284fr_CH.utf8
285fr_FR
286fr_FR@euro
287fr_FR.utf8
288fr_FR.utf8@euro
289fr_LU
290fr_LU@euro
291fr_LU.utf8
292fr_LU.utf8@euro
293ga_IE
294ga_IE@euro
295ga_IE.utf8
296ga_IE.utf8@euro
297gl_ES
298gl_ES@euro
299gl_ES.utf8
300gl_ES.utf8@euro
301gv_GB
302gv_GB.utf8
303he_IL
304he_IL.utf8
305hi_IN
306hr_HR
307hr_HR.utf8
308hu_HU
309hu_HU.utf8
310id_ID
311id_ID.utf8
312is_IS
313is_IS.utf8
314it_CH
315it_CH.utf8
316it_IT
317it_IT@euro
318it_IT.utf8
319it_IT.utf8@euro
320iw_IL
321iw_IL.utf8
322ja_JP.eucjp
323ja_JP.utf8
324ka_GE
325kl_GL
326kl_GL.utf8
327ko_KR.euckr
328ko_KR.utf8
329kw_GB
330kw_GB.utf8
331lt_LT
332lt_LT.utf8
333lv_LV
334lv_LV.utf8
335mi_NZ
336mk_MK
337mk_MK.utf8
338mr_IN
339ms_MY
340ms_MY.utf8
341mt_MT
342mt_MT.utf8
343nl_BE
344nl_BE@euro
345nl_BE.utf8
346nl_BE.utf8@euro
347nl_NL
348nl_NL@euro
349nl_NL.utf8
350nl_NL.utf8@euro
351nn_NO
352nn_NO.utf8
353no_NO
354no_NO.utf8
355oc_FR
356pl_PL
357pl_PL.utf8
358POSIX
359pt_BR
360pt_BR.utf8
361pt_PT
362pt_PT@euro
363pt_PT.utf8
364pt_PT.utf8@euro
365ro_RO
366ro_RO.utf8
367ru_RU
368ru_RU.koi8r
369ru_RU.utf8
370ru_UA
371ru_UA.utf8
372se_NO
373sk_SK
374sk_SK.utf8
375sl_SI
376sl_SI.utf8
377sq_AL
378sq_AL.utf8
379sr_YU
380sr_YU@cyrillic
381sr_YU.utf8
382sr_YU.utf8@cyrillic
383sv_FI
384sv_FI@euro
385sv_FI.utf8
386sv_FI.utf8@euro
387sv_SE
388sv_SE.iso885915
389sv_SE.utf8
390ta_IN
391te_IN
392tg_TJ
393th_TH
394th_TH.utf8
395tl_PH
396tr_TR
397tr_TR.utf8
398uk_UA
399uk_UA.utf8
400ur_PK
401uz_UZ
402vi_VN
403vi_VN.tcvn
404wa_BE
405wa_BE@euro
406yi_US
407zh_CN
408zh_CN.gb18030
409zh_CN.gbk
410zh_CN.utf8
411zh_HK
412zh_HK.utf8
413zh_TW
414zh_TW.euctw
415zh_TW.utf8
416</programlisting>
417</blockquote>
418</listitem>
419
420   <listitem>
421     <para>
422       <code>`locale`</code> displays environmental variables that
423       impact how locale("") will be deduced.
424     </para>
425<blockquote>
426<programlisting>
427LANG=en_US
428LC_CTYPE="en_US"
429LC_NUMERIC="en_US"
430LC_TIME="en_US"
431LC_COLLATE="en_US"
432LC_MONETARY="en_US"
433LC_MESSAGES="en_US"
434LC_PAPER="en_US"
435LC_NAME="en_US"
436LC_ADDRESS="en_US"
437LC_TELEPHONE="en_US"
438LC_MEASUREMENT="en_US"
439LC_IDENTIFICATION="en_US"
440LC_ALL=
441</programlisting>
442</blockquote>
443</listitem>
444</itemizedlist>
445
446<para>
447From Josuttis, p. 697-698, which says, that "there is only *one*
448relation (of the C++ locale mechanism) to the C locale mechanism: the
449global C locale is modified if a named C++ locale object is set as the
450global locale" (emphasis Paolo), that is:
451</para>
452
453<programlisting>std::locale::global(std::locale(""));</programlisting>
454
455<para>affects the C functions as if the following call was made:</para>
456
457<programlisting>std::setlocale(LC_ALL, "");</programlisting>
458
459<para>
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.
465</para>
466
467  </section>
468</section>
469
470<section xml:id="locales.locale.future"><info><title>Future</title></info>
471
472
473<itemizedlist>
474   <listitem>
475     <para>
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?
479     </para>
480     </listitem>
481
482   <listitem>
483     <para>
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?
488   </para>
489   </listitem>
490
491   <listitem>
492     <para>
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").
497     </para>
498   </listitem>
499
500   <listitem>
501     <para>
502       What should non-required facet instantiations do?  If the
503       generic implementation is provided, then how to end-users
504       provide specializations?
505   </para>
506   </listitem>
507</itemizedlist>
508</section>
509
510<bibliography xml:id="locales.locale.biblio"><info><title>Bibliography</title></info>
511
512
513  <biblioentry>
514    <citetitle>
515      The GNU C Library
516    </citetitle>
517    <author><personname><surname>McGrath</surname><firstname>Roland</firstname></personname></author>
518    <author><personname><surname>Drepper</surname><firstname>Ulrich</firstname></personname></author>
519    <copyright>
520      <year>2007</year>
521      <holder>FSF</holder>
522    </copyright>
523    <pagenums>
524      Chapters 6 Character Set Handling and 7 Locales and
525      Internationalization
526    </pagenums>
527  </biblioentry>
528
529  <biblioentry>
530    <citetitle>
531      Correspondence
532    </citetitle>
533    <author><personname><surname>Drepper</surname><firstname>Ulrich</firstname></personname></author>
534    <copyright>
535      <year>2002</year>
536      <holder/>
537    </copyright>
538  </biblioentry>
539
540  <biblioentry>
541    <citetitle>
542      ISO/IEC 14882:1998 Programming languages - C++
543    </citetitle>
544    <copyright>
545      <year>1998</year>
546      <holder>ISO</holder>
547    </copyright>
548  </biblioentry>
549
550  <biblioentry>
551    <citetitle>
552      ISO/IEC 9899:1999 Programming languages - C
553    </citetitle>
554    <copyright>
555      <year>1999</year>
556      <holder>ISO</holder>
557    </copyright>
558  </biblioentry>
559
560  <biblioentry>
561      <title>
562	<link xmlns:xlink="http://www.w3.org/1999/xlink"
563	      xlink:href="http://pubs.opengroup.org/onlinepubs/9699919799/">
564      System Interface Definitions, Issue 7 (IEEE Std. 1003.1-2008)
565	</link>
566      </title>
567    <copyright>
568      <year>2008</year>
569      <holder>
570	The Open Group/The Institute of Electrical and Electronics
571	Engineers, Inc.
572      </holder>
573    </copyright>
574  </biblioentry>
575
576  <biblioentry>
577    <citetitle>
578      The C++ Programming Language, Special Edition
579    </citetitle>
580    <author><personname><surname>Stroustrup</surname><firstname>Bjarne</firstname></personname></author>
581    <copyright>
582      <year>2000</year>
583      <holder>Addison Wesley, Inc.</holder>
584    </copyright>
585    <pagenums>Appendix D</pagenums>
586    <publisher>
587      <publishername>
588	Addison Wesley
589      </publishername>
590    </publisher>
591  </biblioentry>
592
593  <biblioentry>
594    <citetitle>
595      Standard C++ IOStreams and Locales
596    </citetitle>
597    <subtitle>
598      Advanced Programmer's Guide and Reference
599    </subtitle>
600    <author><personname><surname>Langer</surname><firstname>Angelika</firstname></personname></author>
601    <author><personname><surname>Kreft</surname><firstname>Klaus</firstname></personname></author>
602    <copyright>
603      <year>2000</year>
604      <holder>Addison Wesley Longman, Inc.</holder>
605    </copyright>
606    <publisher>
607      <publishername>
608	Addison Wesley Longman
609      </publishername>
610    </publisher>
611  </biblioentry>
612
613</bibliography>
614
615</section>
616