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>Chapter 8. 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="Part II. Standard Contents" /><link rel="prev" href="strings.html" title="Chapter 7. 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">Chapter 8. 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">Part II. 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>Chapter 8. 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> 11Describes the basic locale object, including nested 12classes id, facet, and the reference-counted implementation object, 13class _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> 15Class locale is non-templatized and has two distinct types nested 16inside of it: 17</p><div class="blockquote"><blockquote class="blockquote"><p> 18<span class="emphasis"><em> 19class facet 2022.1.1.1.2 Class locale::facet 21</em></span> 22</p></blockquote></div><p> 23Facets actually implement locale functionality. For instance, a facet 24called numpunct is the data object that can be used to query for the 25thousands separator in the locale. 26</p><p> 27Literally, 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> 37Of interest in this class are the memory management options explicitly 38specified as an argument to facet's constructor. Each constructor of a 39facet class takes a std::size_t __refs argument: if __refs == 0, the 40facet is deleted when the locale containing it is destroyed. If __refs 41== 1, the facet is not destroyed, even when it is no longer 42referenced. 43</p><div class="blockquote"><blockquote class="blockquote"><p> 44<span class="emphasis"><em> 45class id 4622.1.1.1.3 - Class locale::id 47</em></span> 48</p></blockquote></div><p> 49Provides 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> 51The major design challenge is fitting an object-orientated and 52non-global locale design on top of POSIX and other relevant standards, 53which include the Single Unix (nee X/Open.) 54</p><p> 55Because C and earlier versions of POSIX fall down so completely, 56portability 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"> 60af_ZA 61ar_AE 62ar_AE.utf8 63ar_BH 64ar_BH.utf8 65ar_DZ 66ar_DZ.utf8 67ar_EG 68ar_EG.utf8 69ar_IN 70ar_IQ 71ar_IQ.utf8 72ar_JO 73ar_JO.utf8 74ar_KW 75ar_KW.utf8 76ar_LB 77ar_LB.utf8 78ar_LY 79ar_LY.utf8 80ar_MA 81ar_MA.utf8 82ar_OM 83ar_OM.utf8 84ar_QA 85ar_QA.utf8 86ar_SA 87ar_SA.utf8 88ar_SD 89ar_SD.utf8 90ar_SY 91ar_SY.utf8 92ar_TN 93ar_TN.utf8 94ar_YE 95ar_YE.utf8 96be_BY 97be_BY.utf8 98bg_BG 99bg_BG.utf8 100br_FR 101bs_BA 102C 103ca_ES 104ca_ES@euro 105ca_ES.utf8 106ca_ES.utf8@euro 107cs_CZ 108cs_CZ.utf8 109cy_GB 110da_DK 111da_DK.iso885915 112da_DK.utf8 113de_AT 114de_AT@euro 115de_AT.utf8 116de_AT.utf8@euro 117de_BE 118de_BE@euro 119de_BE.utf8 120de_BE.utf8@euro 121de_CH 122de_CH.utf8 123de_DE 124de_DE@euro 125de_DE.utf8 126de_DE.utf8@euro 127de_LU 128de_LU@euro 129de_LU.utf8 130de_LU.utf8@euro 131el_GR 132el_GR.utf8 133en_AU 134en_AU.utf8 135en_BW 136en_BW.utf8 137en_CA 138en_CA.utf8 139en_DK 140en_DK.utf8 141en_GB 142en_GB.iso885915 143en_GB.utf8 144en_HK 145en_HK.utf8 146en_IE 147en_IE@euro 148en_IE.utf8 149en_IE.utf8@euro 150en_IN 151en_NZ 152en_NZ.utf8 153en_PH 154en_PH.utf8 155en_SG 156en_SG.utf8 157en_US 158en_US.iso885915 159en_US.utf8 160en_ZA 161en_ZA.utf8 162en_ZW 163en_ZW.utf8 164es_AR 165es_AR.utf8 166es_BO 167es_BO.utf8 168es_CL 169es_CL.utf8 170es_CO 171es_CO.utf8 172es_CR 173es_CR.utf8 174es_DO 175es_DO.utf8 176es_EC 177es_EC.utf8 178es_ES 179es_ES@euro 180es_ES.utf8 181es_ES.utf8@euro 182es_GT 183es_GT.utf8 184es_HN 185es_HN.utf8 186es_MX 187es_MX.utf8 188es_NI 189es_NI.utf8 190es_PA 191es_PA.utf8 192es_PE 193es_PE.utf8 194es_PR 195es_PR.utf8 196es_PY 197es_PY.utf8 198es_SV 199es_SV.utf8 200es_US 201es_US.utf8 202es_UY 203es_UY.utf8 204es_VE 205es_VE.utf8 206et_EE 207et_EE.utf8 208eu_ES 209eu_ES@euro 210eu_ES.utf8 211eu_ES.utf8@euro 212fa_IR 213fi_FI 214fi_FI@euro 215fi_FI.utf8 216fi_FI.utf8@euro 217fo_FO 218fo_FO.utf8 219fr_BE 220fr_BE@euro 221fr_BE.utf8 222fr_BE.utf8@euro 223fr_CA 224fr_CA.utf8 225fr_CH 226fr_CH.utf8 227fr_FR 228fr_FR@euro 229fr_FR.utf8 230fr_FR.utf8@euro 231fr_LU 232fr_LU@euro 233fr_LU.utf8 234fr_LU.utf8@euro 235ga_IE 236ga_IE@euro 237ga_IE.utf8 238ga_IE.utf8@euro 239gl_ES 240gl_ES@euro 241gl_ES.utf8 242gl_ES.utf8@euro 243gv_GB 244gv_GB.utf8 245he_IL 246he_IL.utf8 247hi_IN 248hr_HR 249hr_HR.utf8 250hu_HU 251hu_HU.utf8 252id_ID 253id_ID.utf8 254is_IS 255is_IS.utf8 256it_CH 257it_CH.utf8 258it_IT 259it_IT@euro 260it_IT.utf8 261it_IT.utf8@euro 262iw_IL 263iw_IL.utf8 264ja_JP.eucjp 265ja_JP.utf8 266ka_GE 267kl_GL 268kl_GL.utf8 269ko_KR.euckr 270ko_KR.utf8 271kw_GB 272kw_GB.utf8 273lt_LT 274lt_LT.utf8 275lv_LV 276lv_LV.utf8 277mi_NZ 278mk_MK 279mk_MK.utf8 280mr_IN 281ms_MY 282ms_MY.utf8 283mt_MT 284mt_MT.utf8 285nl_BE 286nl_BE@euro 287nl_BE.utf8 288nl_BE.utf8@euro 289nl_NL 290nl_NL@euro 291nl_NL.utf8 292nl_NL.utf8@euro 293nn_NO 294nn_NO.utf8 295no_NO 296no_NO.utf8 297oc_FR 298pl_PL 299pl_PL.utf8 300POSIX 301pt_BR 302pt_BR.utf8 303pt_PT 304pt_PT@euro 305pt_PT.utf8 306pt_PT.utf8@euro 307ro_RO 308ro_RO.utf8 309ru_RU 310ru_RU.koi8r 311ru_RU.utf8 312ru_UA 313ru_UA.utf8 314se_NO 315sk_SK 316sk_SK.utf8 317sl_SI 318sl_SI.utf8 319sq_AL 320sq_AL.utf8 321sr_YU 322sr_YU@cyrillic 323sr_YU.utf8 324sr_YU.utf8@cyrillic 325sv_FI 326sv_FI@euro 327sv_FI.utf8 328sv_FI.utf8@euro 329sv_SE 330sv_SE.iso885915 331sv_SE.utf8 332ta_IN 333te_IN 334tg_TJ 335th_TH 336th_TH.utf8 337tl_PH 338tr_TR 339tr_TR.utf8 340uk_UA 341uk_UA.utf8 342ur_PK 343uz_UZ 344vi_VN 345vi_VN.tcvn 346wa_BE 347wa_BE@euro 348yi_US 349zh_CN 350zh_CN.gb18030 351zh_CN.gbk 352zh_CN.utf8 353zh_HK 354zh_HK.utf8 355zh_TW 356zh_TW.euctw 357zh_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"> 362LANG=en_US 363LC_CTYPE="en_US" 364LC_NUMERIC="en_US" 365LC_TIME="en_US" 366LC_COLLATE="en_US" 367LC_MONETARY="en_US" 368LC_MESSAGES="en_US" 369LC_PAPER="en_US" 370LC_NAME="en_US" 371LC_ADDRESS="en_US" 372LC_TELEPHONE="en_US" 373LC_MEASUREMENT="en_US" 374LC_IDENTIFICATION="en_US" 375LC_ALL= 376</pre></blockquote></div></li></ul></div><p> 377From Josuttis, p. 697-698, which says, that "there is only *one* 378relation (of the C++ locale mechanism) to the C locale mechanism: the 379global C locale is modified if a named C++ locale object is set as the 380global 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">Chapter 7. 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>