OSDN Git Service

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