1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Chapter 8. Localization</title><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"/><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="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><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 8.
6 </th></tr><tr><td align="left"><a accesskey="p" href="strings.html">Prev</a> </td><th width="60%" align="center">Part II.
8 </th><td 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 id="std.localization"/>Chapter 8.
10 <a id="id648384" class="indexterm"/>
11 </h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></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#id649036">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"><a id="std.localization.locales"/>Locales</h2></div></div></div><div class="section" title="locale"><div class="titlepage"><div><div><h3 class="title"><a id="std.localization.locales.locale"/>locale</h3></div></div></div><p>
12 Describes the basic locale object, including nested
13 classes id, facet, and the reference-counted implementation object,
15 </p><div class="section" title="Requirements"><div class="titlepage"><div><div><h4 class="title"><a id="locales.locale.req"/>Requirements</h4></div></div></div><p>
16 Class locale is non-templatized and has two distinct types nested
18 </p><div class="blockquote"><blockquote class="blockquote"><p>
19 <span class="emphasis"><em>
21 22.1.1.1.2 Class locale::facet
23 </p></blockquote></div><p>
24 Facets actually implement locale functionality. For instance, a facet
25 called numpunct is the data object that can be used to query for the
26 thousands separator in the locale.
28 Literally, a facet is strictly defined:
29 </p><div class="itemizedlist"><ul class="itemizedlist"><li class="listitem"><p>
30 Containing the following public data member:
32 <code class="code">static locale::id id;</code>
33 </p></li><li class="listitem"><p>
34 Derived from another facet:
36 <code class="code">class gnu_codecvt: public std::ctype<user-defined-type></code>
37 </p></li></ul></div><p>
38 Of interest in this class are the memory management options explicitly
39 specified as an argument to facet's constructor. Each constructor of a
40 facet class takes a std::size_t __refs argument: if __refs == 0, the
41 facet is deleted when the locale containing it is destroyed. If __refs
42 == 1, the facet is not destroyed, even when it is no longer
44 </p><div class="blockquote"><blockquote class="blockquote"><p>
45 <span class="emphasis"><em>
47 22.1.1.1.3 - Class locale::id
49 </p></blockquote></div><p>
50 Provides an index for looking up specific facets.
51 </p></div><div class="section" title="Design"><div class="titlepage"><div><div><h4 class="title"><a id="locales.locale.design"/>Design</h4></div></div></div><p>
52 The major design challenge is fitting an object-orientated and
53 non-global locale design on top of POSIX and other relevant standards,
54 which include the Single Unix (nee X/Open.)
56 Because C and earlier versions of POSIX fall down so completely,
57 portability is an issue.
58 </p></div><div class="section" title="Implementation"><div class="titlepage"><div><div><h4 class="title"><a id="locales.locale.impl"/>Implementation</h4></div></div></div><div class="section" title="Interacting with "C" locales"><div class="titlepage"><div><div><h5 class="title"><a id="locale.impl.c"/>Interacting with "C" locales</h5></div></div></div><div class="itemizedlist"><ul class="itemizedlist"><li class="listitem"><p>
59 <code class="code">`locale -a`</code> displays available locales.
60 </p><div class="blockquote"><blockquote class="blockquote"><pre class="programlisting">
359 </pre></blockquote></div></li><li class="listitem"><p>
360 <code class="code">`locale`</code> displays environmental variables that
361 impact how locale("") will be deduced.
362 </p><div class="blockquote"><blockquote class="blockquote"><pre class="programlisting">
374 LC_MEASUREMENT="en_US"
375 LC_IDENTIFICATION="en_US"
377 </pre></blockquote></div></li></ul></div><p>
378 From Josuttis, p. 697-698, which says, that "there is only *one*
379 relation (of the C++ locale mechanism) to the C locale mechanism: the
380 global C locale is modified if a named C++ locale object is set as the
381 global locale" (emphasis Paolo), that is:
382 </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>
383 On the other hand, there is *no* vice versa, that is, calling
384 setlocale has *no* whatsoever on the C++ locale mechanism, in
385 particular on the working of locale(""), which constructs the locale
386 object from the environment of the running program, that is, in
387 practice, the set of LC_ALL, LANG, etc. variable of the shell.
388 </p></div></div><div class="section" title="Future"><div class="titlepage"><div><div><h4 class="title"><a id="locales.locale.future"/>Future</h4></div></div></div><div class="itemizedlist"><ul class="itemizedlist"><li class="listitem"><p>
389 Locale initialization: at what point does _S_classic, _S_global
390 get initialized? Can named locales assume this initialization
391 has already taken place?
392 </p></li><li class="listitem"><p>
393 Document how named locales error check when filling data
394 members. I.e., a fr_FR locale that doesn't have
395 numpunct::truename(): does it use "true"? Or is it a blank
396 string? What's the convention?
397 </p></li><li class="listitem"><p>
398 Explain how locale aliasing happens. When does "de_DE" use "de"
399 information? What is the rule for locales composed of just an
400 ISO language code (say, "de") and locales with both an ISO
401 language code and ISO country code (say, "de_DE").
402 </p></li><li class="listitem"><p>
403 What should non-required facet instantiations do? If the
404 generic implementation is provided, then how to end-users
405 provide specializations?
406 </p></li></ul></div></div><div class="bibliography" title="Bibliography"><div class="titlepage"><div><div><h4 class="title"><a id="locales.locale.biblio"/>Bibliography</h4></div></div></div><div class="biblioentry"><a id="id648747"/><p><span class="citetitle"><em class="citetitle">
408 </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">
409 Chapters 6 Character Set Handling and 7 Locales and
411 . </span></p></div><div class="biblioentry"><a id="id648786"/><p><span class="citetitle"><em class="citetitle">
413 </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="id648812"/><p><span class="citetitle"><em class="citetitle">
414 ISO/IEC 14882:1998 Programming languages - C++
415 </em>. </span><span class="copyright">Copyright © 1998 ISO. </span></p></div><div class="biblioentry"><a id="id648831"/><p><span class="citetitle"><em class="citetitle">
416 ISO/IEC 9899:1999 Programming languages - C
417 </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 id="id648850"/><p><span class="title"><em>
418 <a class="link" href="http://www.opengroup.org/austin/">
419 System Interface Definitions, Issue 7 (IEEE Std. 1003.1-2008)
421 </em>. </span><span class="copyright">Copyright © 2008
422 The Open Group/The Institute of Electrical and Electronics
424 . </span></p></div><div class="biblioentry"><a id="id648877"/><p><span class="citetitle"><em class="citetitle">
425 The C++ Programming Language, Special Edition
426 </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">
428 . </span></span></p></div><div class="biblioentry"><a id="id648916"/><p><span class="citetitle"><em class="citetitle">
429 Standard C++ IOStreams and Locales
430 </em>. </span><span class="subtitle">
431 Advanced Programmer's Guide and Reference
432 . </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">
433 Addison Wesley Longman
434 . </span></span></p></div></div></div></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td align="left"><a accesskey="p" href="strings.html">Prev</a> </td><td align="center"><a accesskey="u" href="bk01pt02.html">Up</a></td><td align="right"> <a accesskey="n" href="facets.html">Next</a></td></tr><tr><td align="left" valign="top">Chapter 7.
437 </td><td align="center"><a accesskey="h" href="../index.html">Home</a></td><td align="right" valign="top"> Facets</td></tr></table></div></body></html>