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