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.73.2" /><meta name="keywords" content=" ISO C++ , library " /><link rel="start" 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="bk01pt06ch15.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. Localization</th><td width="20%" align="right"> <a accesskey="n" href="bk01pt06ch15.html">Next</a></td></tr></table><hr /></div><div class="chapter" lang="en" xml:lang="en"><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="bk01pt06ch14.html#manual.localization.locales.locale">locale</a></span></dt><dd><dl><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.req">Requirements</a></span></dt><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.design">Design</a></span></dt><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.impl">Implementation</a></span></dt><dt><span class="sect2"><a href="bk01pt06ch14.html#locales.locale.future">Future</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.localization.locales.locale"></a>locale</h2></div></div></div><p>
4 Describes the basic locale object, including nested
5 classes id, facet, and the reference-counted implementation object,
7 </p><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.req"></a>Requirements</h3></div></div></div><p>
8 Class locale is non-templatized and has two distinct types nested
10 </p><div class="blockquote"><blockquote class="blockquote"><p>
11 <span class="emphasis"><em>
13 22.1.1.1.2 Class locale::facet
15 </p></blockquote></div><p>
16 Facets actually implement locale functionality. For instance, a facet
17 called numpunct is the data objects that can be used to query for the
18 thousands separator is in the German locale.
20 Literally, a facet is strictly defined:
21 </p><div class="itemizedlist"><ul type="disc"><li><p>
22 Containing the following public data member:
24 <code class="code">static locale::id id;</code>
26 Derived from another facet:
28 <code class="code">class gnu_codecvt: public std::ctype<user-defined-type></code>
29 </p></li></ul></div><p>
30 Of interest in this class are the memory management options explicitly
31 specified as an argument to facet's constructor. Each constructor of a
32 facet class takes a std::size_t __refs argument: if __refs == 0, the
33 facet is deleted when the locale containing it is destroyed. If __refs
34 == 1, the facet is not destroyed, even when it is no longer
36 </p><div class="blockquote"><blockquote class="blockquote"><p>
37 <span class="emphasis"><em>
39 22.1.1.1.3 - Class locale::id
41 </p></blockquote></div><p>
42 Provides an index for looking up specific facets.
43 </p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.design"></a>Design</h3></div></div></div><p>
44 The major design challenge is fitting an object-orientated and
45 non-global locale design on top of POSIX and other relevant standards,
46 which include the Single Unix (nee X/Open.)
48 Because C and earlier versions of POSIX falls down so completely,
49 portability is an issue.
50 </p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.impl"></a>Implementation</h3></div></div></div><div class="sect3" lang="en" xml:lang="en"><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 type="disc"><li><p>
51 <code class="code">`locale -a`</code> displays available locales.
52 </p><div class="blockquote"><blockquote class="blockquote"><pre class="programlisting">
351 </pre></blockquote></div></li><li><p>
352 <code class="code">`locale`</code> displays environmental variables that
353 impact how locale("") will be deduced.
354 </p><div class="blockquote"><blockquote class="blockquote"><pre class="programlisting">
366 LC_MEASUREMENT="en_US"
367 LC_IDENTIFICATION="en_US"
369 </pre></blockquote></div></li></ul></div><p>
370 From Josuttis, p. 697-698, which says, that "there is only *one*
371 relation (of the C++ locale mechanism) to the C locale mechanism: the
372 global C locale is modified if a named C++ locale object is set as the
373 global locale" (emphasis Paolo), that is:
374 </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>
375 On the other hand, there is *no* vice versa, that is, calling
376 setlocale has *no* whatsoever on the C++ locale mechanism, in
377 particular on the working of locale(""), which constructs the locale
378 object from the environment of the running program, that is, in
379 practice, the set of LC_ALL, LANG, etc. variable of the shell.
380 </p></div></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.future"></a>Future</h3></div></div></div><div class="itemizedlist"><ul type="disc"><li><p>
381 Locale initialization: at what point does _S_classic, _S_global
382 get initialized? Can named locales assume this initialization
383 has already taken place?
385 Document how named locales error check when filling data
386 members. I.e., a fr_FR locale that doesn't have
387 numpunct::truename(): does it use "true"? Or is it a blank
388 string? What's the convention?
390 Explain how locale aliasing happens. When does "de_DE" use "de"
391 information? What is the rule for locales composed of just an
392 ISO language code (say, "de") and locales with both an ISO
393 language code and ISO country code (say, "de_DE").
395 What should non-required facet instantiations do? If the
396 generic implementation is provided, then how to end-users
397 provide specializations?
398 </p></li></ul></div></div><div class="bibliography"><div class="titlepage"><div><div><h3 class="title"><a id="locales.locale.biblio"></a>Bibliography</h3></div></div></div><div class="biblioentry"><a id="id412273"></a><p><span class="title"><i>
400 </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"><a id="id398173"></a><p><span class="title"><i>
402 </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"><a id="id427688"></a><p><span class="title"><i>
403 ISO/IEC 14882:1998 Programming languages - C++
404 </i>. </span><span class="copyright">Copyright © 1998 ISO. </span></p></div><div class="biblioentry"><a id="id427707"></a><p><span class="title"><i>
405 ISO/IEC 9899:1999 Programming languages - C
406 </i>. </span><span class="copyright">Copyright © 1999 ISO. </span></p></div><div class="biblioentry"><a id="id406617"></a><p><span class="title"><i>
407 System Interface Definitions, Issue 6 (IEEE Std. 1003.1-200x)
408 </i>. </span><span class="copyright">Copyright © 1999
409 The Open Group/The Institute of Electrical and Electronics Engineers, Inc.. </span><span class="biblioid">
410 <a class="ulink" href="http://www.opennc.org/austin/docreg.html" target="_top">
412 . </span></p></div><div class="biblioentry"><a id="id471678"></a><p><span class="title"><i>
413 The C++ Programming Language, Special Edition
414 </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">
416 . </span></span></p></div><div class="biblioentry"><a id="id414572"></a><p><span class="title"><i>
417 Standard C++ IOStreams and Locales
418 </i>. </span><span class="subtitle">
419 Advanced Programmer's Guide and Reference
420 . </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">
421 Addison Wesley Longman
422 . </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="bk01pt06ch15.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Part VI. Localization </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>