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