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