OSDN Git Service

2008-04-10 Benjamin Kosnik <bkoz@redhat.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / doc / html / manual / bk01pt06ch14.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 14. Locales</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="&#10;      ISO C++&#10;    , &#10;      library&#10;    " /><link rel="start" href="../spine.html" title="The GNU C++ Library Documentation" /><link rel="up" href="localization.html" title="Part VI. Localization" /><link rel="prev" href="localization.html" title="Part VI. Localization" /><link rel="next" href="bk01pt06ch15.html" title="Chapter 15. Facets aka Categories" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 14. Locales</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="localization.html">Prev</a> </td><th width="60%" align="center">Part VI. Localization</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt06ch15.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="manual.localization.locales"></a>Chapter 14. Locales</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="bk01pt06ch14.html#manual.localization.locales.locale">locale</a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.req">Requirements</a></span></dt><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.design">Design</a></span></dt><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.impl">Implementation</a></span></dt><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.future">Future</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.localization.locales.locale"></a>locale</h2></div></div></div><p>
4 Describes the basic locale object, including nested
5 classes id, facet, and the reference-counted implementation object,
6 class _Impl.
7 </p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.req"></a>Requirements</h3></div></div></div><p>
8 Class locale is non-templatized and has two distinct types nested
9 inside of it:
10 </p><div class="blockquote"><blockquote class="blockquote"><p>
11 <span class="emphasis"><em>
12 class facet
13 22.1.1.1.2 Class locale::facet
14 </em></span>
15 </p></blockquote></div><p>
16 Facets actually implement locale functionality. For instance, a facet
17 called numpunct is the data objects that can be used to query for the
18 thousands separator is in the German locale.
19 </p><p>
20 Literally, a facet is strictly defined:
21 </p><div class="itemizedlist"><ul type="disc"><li><p>
22       Containing the following public data member:
23     </p><p>
24       <code class="code">static locale::id id;</code>
25     </p></li><li><p>
26       Derived from another facet:
27     </p><p>
28       <code class="code">class gnu_codecvt: public std::ctype&lt;user-defined-type&gt;</code>
29     </p></li></ul></div><p>
30 Of interest in this class are the memory management options explicitly
31 specified as an argument to facet's constructor. Each constructor of a
32 facet class takes a std::size_t __refs argument: if __refs == 0, the
33 facet is deleted when the locale containing it is destroyed. If __refs
34 == 1, the facet is not destroyed, even when it is no longer
35 referenced.
36 </p><div class="blockquote"><blockquote class="blockquote"><p>
37 <span class="emphasis"><em>
38 class id
39 22.1.1.1.3 - Class locale::id
40 </em></span>
41 </p></blockquote></div><p>
42 Provides an index for looking up specific facets.
43 </p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.design"></a>Design</h3></div></div></div><p>
44 The major design challenge is fitting an object-orientated and
45 non-global locale design on top of POSIX and other relevant standards,
46 which include the Single Unix (nee X/Open.)
47 </p><p>
48 Because C and earlier versions of POSIX falls down so completely,
49 portability is an issue.
50 </p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.impl"></a>Implementation</h3></div></div></div><div class="sect3" lang="en" xml:lang="en"><div class="titlepage"><div><div><h4 class="title"><a id="locale.impl.c"></a>Interacting with "C" locales</h4></div></div></div><div class="itemizedlist"><ul type="disc"><li><p> 
51        <code class="code">`locale -a`</code> displays available locales. 
52      </p><div class="blockquote"><blockquote class="blockquote"><pre class="programlisting">
53 af_ZA
54 ar_AE
55 ar_AE.utf8
56 ar_BH
57 ar_BH.utf8
58 ar_DZ
59 ar_DZ.utf8
60 ar_EG
61 ar_EG.utf8
62 ar_IN
63 ar_IQ
64 ar_IQ.utf8
65 ar_JO
66 ar_JO.utf8
67 ar_KW
68 ar_KW.utf8
69 ar_LB
70 ar_LB.utf8
71 ar_LY
72 ar_LY.utf8
73 ar_MA
74 ar_MA.utf8
75 ar_OM
76 ar_OM.utf8
77 ar_QA
78 ar_QA.utf8
79 ar_SA
80 ar_SA.utf8
81 ar_SD
82 ar_SD.utf8
83 ar_SY
84 ar_SY.utf8
85 ar_TN
86 ar_TN.utf8
87 ar_YE
88 ar_YE.utf8
89 be_BY
90 be_BY.utf8
91 bg_BG
92 bg_BG.utf8
93 br_FR
94 bs_BA
95 C
96 ca_ES
97 ca_ES@euro
98 ca_ES.utf8
99 ca_ES.utf8@euro
100 cs_CZ
101 cs_CZ.utf8
102 cy_GB
103 da_DK
104 da_DK.iso885915
105 da_DK.utf8
106 de_AT
107 de_AT@euro
108 de_AT.utf8
109 de_AT.utf8@euro
110 de_BE
111 de_BE@euro
112 de_BE.utf8
113 de_BE.utf8@euro
114 de_CH
115 de_CH.utf8
116 de_DE
117 de_DE@euro
118 de_DE.utf8
119 de_DE.utf8@euro
120 de_LU
121 de_LU@euro
122 de_LU.utf8
123 de_LU.utf8@euro
124 el_GR
125 el_GR.utf8
126 en_AU
127 en_AU.utf8
128 en_BW
129 en_BW.utf8
130 en_CA
131 en_CA.utf8
132 en_DK
133 en_DK.utf8
134 en_GB
135 en_GB.iso885915
136 en_GB.utf8
137 en_HK
138 en_HK.utf8
139 en_IE
140 en_IE@euro
141 en_IE.utf8
142 en_IE.utf8@euro
143 en_IN
144 en_NZ
145 en_NZ.utf8
146 en_PH
147 en_PH.utf8
148 en_SG
149 en_SG.utf8
150 en_US
151 en_US.iso885915
152 en_US.utf8
153 en_ZA
154 en_ZA.utf8
155 en_ZW
156 en_ZW.utf8
157 es_AR
158 es_AR.utf8
159 es_BO
160 es_BO.utf8
161 es_CL
162 es_CL.utf8
163 es_CO
164 es_CO.utf8
165 es_CR
166 es_CR.utf8
167 es_DO
168 es_DO.utf8
169 es_EC
170 es_EC.utf8
171 es_ES
172 es_ES@euro
173 es_ES.utf8
174 es_ES.utf8@euro
175 es_GT
176 es_GT.utf8
177 es_HN
178 es_HN.utf8
179 es_MX
180 es_MX.utf8
181 es_NI
182 es_NI.utf8
183 es_PA
184 es_PA.utf8
185 es_PE
186 es_PE.utf8
187 es_PR
188 es_PR.utf8
189 es_PY
190 es_PY.utf8
191 es_SV
192 es_SV.utf8
193 es_US
194 es_US.utf8
195 es_UY
196 es_UY.utf8
197 es_VE
198 es_VE.utf8
199 et_EE
200 et_EE.utf8
201 eu_ES
202 eu_ES@euro
203 eu_ES.utf8
204 eu_ES.utf8@euro
205 fa_IR
206 fi_FI
207 fi_FI@euro
208 fi_FI.utf8
209 fi_FI.utf8@euro
210 fo_FO
211 fo_FO.utf8
212 fr_BE
213 fr_BE@euro
214 fr_BE.utf8
215 fr_BE.utf8@euro
216 fr_CA
217 fr_CA.utf8
218 fr_CH
219 fr_CH.utf8
220 fr_FR
221 fr_FR@euro
222 fr_FR.utf8
223 fr_FR.utf8@euro
224 fr_LU
225 fr_LU@euro
226 fr_LU.utf8
227 fr_LU.utf8@euro
228 ga_IE
229 ga_IE@euro
230 ga_IE.utf8
231 ga_IE.utf8@euro
232 gl_ES
233 gl_ES@euro
234 gl_ES.utf8
235 gl_ES.utf8@euro
236 gv_GB
237 gv_GB.utf8
238 he_IL
239 he_IL.utf8
240 hi_IN
241 hr_HR
242 hr_HR.utf8
243 hu_HU
244 hu_HU.utf8
245 id_ID
246 id_ID.utf8
247 is_IS
248 is_IS.utf8
249 it_CH
250 it_CH.utf8
251 it_IT
252 it_IT@euro
253 it_IT.utf8
254 it_IT.utf8@euro
255 iw_IL
256 iw_IL.utf8
257 ja_JP.eucjp
258 ja_JP.utf8
259 ka_GE
260 kl_GL
261 kl_GL.utf8
262 ko_KR.euckr
263 ko_KR.utf8
264 kw_GB
265 kw_GB.utf8
266 lt_LT
267 lt_LT.utf8
268 lv_LV
269 lv_LV.utf8
270 mi_NZ
271 mk_MK
272 mk_MK.utf8
273 mr_IN
274 ms_MY
275 ms_MY.utf8
276 mt_MT
277 mt_MT.utf8
278 nl_BE
279 nl_BE@euro
280 nl_BE.utf8
281 nl_BE.utf8@euro
282 nl_NL
283 nl_NL@euro
284 nl_NL.utf8
285 nl_NL.utf8@euro
286 nn_NO
287 nn_NO.utf8
288 no_NO
289 no_NO.utf8
290 oc_FR
291 pl_PL
292 pl_PL.utf8
293 POSIX
294 pt_BR
295 pt_BR.utf8
296 pt_PT
297 pt_PT@euro
298 pt_PT.utf8
299 pt_PT.utf8@euro
300 ro_RO
301 ro_RO.utf8
302 ru_RU
303 ru_RU.koi8r
304 ru_RU.utf8
305 ru_UA
306 ru_UA.utf8
307 se_NO
308 sk_SK
309 sk_SK.utf8
310 sl_SI
311 sl_SI.utf8
312 sq_AL
313 sq_AL.utf8
314 sr_YU
315 sr_YU@cyrillic
316 sr_YU.utf8
317 sr_YU.utf8@cyrillic
318 sv_FI
319 sv_FI@euro
320 sv_FI.utf8
321 sv_FI.utf8@euro
322 sv_SE
323 sv_SE.iso885915
324 sv_SE.utf8
325 ta_IN
326 te_IN
327 tg_TJ
328 th_TH
329 th_TH.utf8
330 tl_PH
331 tr_TR
332 tr_TR.utf8
333 uk_UA
334 uk_UA.utf8
335 ur_PK
336 uz_UZ
337 vi_VN
338 vi_VN.tcvn
339 wa_BE
340 wa_BE@euro
341 yi_US
342 zh_CN
343 zh_CN.gb18030
344 zh_CN.gbk
345 zh_CN.utf8
346 zh_HK
347 zh_HK.utf8
348 zh_TW
349 zh_TW.euctw
350 zh_TW.utf8
351 </pre></blockquote></div></li><li><p> 
352        <code class="code">`locale`</code> displays environmental variables that
353        impact how locale("") will be deduced.
354      </p><div class="blockquote"><blockquote class="blockquote"><pre class="programlisting">
355 LANG=en_US
356 LC_CTYPE="en_US"
357 LC_NUMERIC="en_US"
358 LC_TIME="en_US"
359 LC_COLLATE="en_US"
360 LC_MONETARY="en_US"
361 LC_MESSAGES="en_US"
362 LC_PAPER="en_US"
363 LC_NAME="en_US"
364 LC_ADDRESS="en_US"
365 LC_TELEPHONE="en_US"
366 LC_MEASUREMENT="en_US"
367 LC_IDENTIFICATION="en_US"
368 LC_ALL=
369 </pre></blockquote></div></li></ul></div><p>
370 From Josuttis, p. 697-698, which says, that "there is only *one*
371 relation (of the C++ locale mechanism) to the C locale mechanism: the
372 global C locale is modified if a named C++ locale object is set as the
373 global locale" (emphasis Paolo), that is:
374 </p><pre class="programlisting">std::locale::global(std::locale(""));</pre><p>affects the C functions as if the following call was made:</p><pre class="programlisting">std::setlocale(LC_ALL, "");</pre><p>
375   On the other hand, there is *no* vice versa, that is, calling
376   setlocale has *no* whatsoever on the C++ locale mechanism, in
377   particular on the working of locale(""), which constructs the locale
378   object from the environment of the running program, that is, in
379   practice, the set of LC_ALL, LANG, etc. variable of the shell.
380 </p></div></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.future"></a>Future</h3></div></div></div><div class="itemizedlist"><ul type="disc"><li><p>
381        Locale initialization: at what point does _S_classic, _S_global
382        get initialized? Can named locales assume this initialization
383        has already taken place? 
384      </p></li><li><p> 
385        Document how named locales error check when filling data
386        members. I.e., a fr_FR locale that doesn't have
387        numpunct::truename(): does it use "true"? Or is it a blank
388        string? What's the convention? 
389    </p></li><li><p> 
390        Explain how locale aliasing happens. When does "de_DE" use "de"
391        information? What is the rule for locales composed of just an
392        ISO language code (say, "de") and locales with both an ISO
393        language code and ISO country code (say, "de_DE"). 
394      </p></li><li><p> 
395        What should non-required facet instantiations do?  If the
396        generic implementation is provided, then how to end-users
397        provide specializations? 
398    </p></li></ul></div></div><div class="bibliography"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.biblio"></a>Bibliography</h3></div></div></div><div class="biblioentry"><a id="id412273"></a><p><span class="title"><i>
399       The GNU C Library
400     </i>. </span><span class="author"><span class="firstname">Roland</span> <span class="surname">McGrath</span>. </span><span class="author"><span class="firstname">Ulrich</span> <span class="surname">Drepper</span>. </span><span class="copyright">Copyright © 2007 FSF. </span><span class="pagenums">Chapters 6 Character Set Handling and 7 Locales and Internationalization. </span></p></div><div class="biblioentry"><a id="id398173"></a><p><span class="title"><i>
401       Correspondence
402     </i>. </span><span class="author"><span class="firstname">Ulrich</span> <span class="surname">Drepper</span>. </span><span class="copyright">Copyright © 2002 . </span></p></div><div class="biblioentry"><a id="id427688"></a><p><span class="title"><i>
403       ISO/IEC 14882:1998 Programming languages - C++
404     </i>. </span><span class="copyright">Copyright © 1998 ISO. </span></p></div><div class="biblioentry"><a id="id427707"></a><p><span class="title"><i>
405       ISO/IEC 9899:1999 Programming languages - C
406     </i>. </span><span class="copyright">Copyright © 1999 ISO. </span></p></div><div class="biblioentry"><a id="id406617"></a><p><span class="title"><i>
407       System Interface Definitions, Issue 6 (IEEE Std. 1003.1-200x)
408     </i>. </span><span class="copyright">Copyright © 1999 
409       The Open Group/The Institute of Electrical and Electronics Engineers, Inc.. </span><span class="biblioid">
410       <a class="ulink" href="http://www.opennc.org/austin/docreg.html" target="_top">
411       </a>
412     . </span></p></div><div class="biblioentry"><a id="id471678"></a><p><span class="title"><i>
413       The C++ Programming Language, Special Edition
414     </i>. </span><span class="author"><span class="firstname">Bjarne</span> <span class="surname">Stroustrup</span>. </span><span class="copyright">Copyright © 2000 Addison Wesley, Inc.. </span><span class="pagenums">Appendix D. </span><span class="publisher"><span class="publishername">
415         Addison Wesley
416       . </span></span></p></div><div class="biblioentry"><a id="id414572"></a><p><span class="title"><i>
417       Standard C++ IOStreams and Locales
418     </i>. </span><span class="subtitle">
419       Advanced Programmer's Guide and Reference
420     . </span><span class="author"><span class="firstname">Angelika</span> <span class="surname">Langer</span>. </span><span class="author"><span class="firstname">Klaus</span> <span class="surname">Kreft</span>. </span><span class="copyright">Copyright © 2000 Addison Wesley Longman, Inc.. </span><span class="publisher"><span class="publishername">
421         Addison Wesley Longman
422       . </span></span></p></div></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="localization.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="localization.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk01pt06ch15.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part VI. Localization </td><td width="20%" align="center"><a accesskey="h" href="../spine.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 15. Facets aka Categories</td></tr></table></div></body></html>