1 <html><head><meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8"><title>Chapter
8. Localization
</title><meta name=
"generator" content=
"DocBook XSL-NS Stylesheets V1.76.1"><meta name=
"keywords" content=
"
5 "><meta name=
"keywords" content=
"
11 "><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 bgcolor=
"white" text=
"black" link=
"#0000FF" vlink=
"#840084" alink=
"#0000FF"><div class=
"navheader"><table width=
"100%" summary=
"Navigation header"><tr><th colspan=
"3" align=
"center">Chapter
8.
14 </th></tr><tr><td width=
"20%" align=
"left"><a accesskey=
"p" href=
"strings.html">Prev
</a> </td><th width=
"60%" align=
"center">Part II.
16 </th><td width=
"20%" 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 name=
"std.localization"></a>Chapter
8.
18 <a class=
"indexterm" name=
"id624511"></a>
19 </h2></div></div></div><div class=
"toc"><p><b>Table of Contents
</b></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#id625164">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" style=
"clear: both"><a name=
"std.localization.locales"></a>Locales
</h2></div></div></div><div class=
"section" title=
"locale"><div class=
"titlepage"><div><div><h3 class=
"title"><a name=
"std.localization.locales.locale"></a>locale
</h3></div></div></div><p>
20 Describes the basic locale object, including nested
21 classes id, facet, and the reference-counted implementation object,
23 </p><div class=
"section" title=
"Requirements"><div class=
"titlepage"><div><div><h4 class=
"title"><a name=
"locales.locale.req"></a>Requirements
</h4></div></div></div><p>
24 Class locale is non-templatized and has two distinct types nested
26 </p><div class=
"blockquote"><blockquote class=
"blockquote"><p>
27 <span class=
"emphasis"><em>
29 22.1.1.1.2 Class locale::facet
31 </p></blockquote></div><p>
32 Facets actually implement locale functionality. For instance, a facet
33 called numpunct is the data object that can be used to query for the
34 thousands separator in the locale.
36 Literally, a facet is strictly defined:
37 </p><div class=
"itemizedlist"><ul class=
"itemizedlist" type=
"disc"><li class=
"listitem"><p>
38 Containing the following public data member:
40 <code class=
"code">static locale::id id;
</code>
41 </p></li><li class=
"listitem"><p>
42 Derived from another facet:
44 <code class=
"code">class gnu_codecvt: public std::ctype
<user-defined-type
></code>
45 </p></li></ul></div><p>
46 Of interest in this class are the memory management options explicitly
47 specified as an argument to facet's constructor. Each constructor of a
48 facet class takes a std::size_t __refs argument: if __refs ==
0, the
49 facet is deleted when the locale containing it is destroyed. If __refs
50 ==
1, the facet is not destroyed, even when it is no longer
52 </p><div class=
"blockquote"><blockquote class=
"blockquote"><p>
53 <span class=
"emphasis"><em>
55 22.1.1.1.3 - Class locale::id
57 </p></blockquote></div><p>
58 Provides an index for looking up specific facets.
59 </p></div><div class=
"section" title=
"Design"><div class=
"titlepage"><div><div><h4 class=
"title"><a name=
"locales.locale.design"></a>Design
</h4></div></div></div><p>
60 The major design challenge is fitting an object-orientated and
61 non-global locale design on top of POSIX and other relevant standards,
62 which include the Single Unix (nee X/Open.)
64 Because C and earlier versions of POSIX fall down so completely,
65 portability is an issue.
66 </p></div><div class=
"section" title=
"Implementation"><div class=
"titlepage"><div><div><h4 class=
"title"><a name=
"locales.locale.impl"></a>Implementation
</h4></div></div></div><div class=
"section" title='Interacting with
"C" locales'
><div class=
"titlepage"><div><div><h5 class=
"title"><a name=
"locale.impl.c"></a>Interacting with
"C" locales
</h5></div></div></div><div class=
"itemizedlist"><ul class=
"itemizedlist" type=
"disc"><li class=
"listitem"><p>
67 <code class=
"code">`locale -a`
</code> displays available locales.
68 </p><div class=
"blockquote"><blockquote class=
"blockquote"><pre class=
"programlisting">
367 </pre></blockquote></div></li><li class=
"listitem"><p>
368 <code class=
"code">`locale`
</code> displays environmental variables that
369 impact how locale(
"") will be deduced.
370 </p><div class=
"blockquote"><blockquote class=
"blockquote"><pre class=
"programlisting">
382 LC_MEASUREMENT=
"en_US"
383 LC_IDENTIFICATION=
"en_US"
385 </pre></blockquote></div></li></ul></div><p>
386 From Josuttis, p.
697-
698, which says, that
"there is only *one*
387 relation (of the C++ locale mechanism) to the C locale mechanism: the
388 global C locale is modified if a named C++ locale object is set as the
389 global locale" (emphasis Paolo), that is:
390 </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>
391 On the other hand, there is *no* vice versa, that is, calling
392 setlocale has *no* whatsoever on the C++ locale mechanism, in
393 particular on the working of locale(
""), which constructs the locale
394 object from the environment of the running program, that is, in
395 practice, the set of LC_ALL, LANG, etc. variable of the shell.
396 </p></div></div><div class=
"section" title=
"Future"><div class=
"titlepage"><div><div><h4 class=
"title"><a name=
"locales.locale.future"></a>Future
</h4></div></div></div><div class=
"itemizedlist"><ul class=
"itemizedlist" type=
"disc"><li class=
"listitem"><p>
397 Locale initialization: at what point does _S_classic, _S_global
398 get initialized? Can named locales assume this initialization
399 has already taken place?
400 </p></li><li class=
"listitem"><p>
401 Document how named locales error check when filling data
402 members. I.e., a fr_FR locale that doesn't have
403 numpunct::truename(): does it use
"true"? Or is it a blank
404 string? What's the convention?
405 </p></li><li class=
"listitem"><p>
406 Explain how locale aliasing happens. When does
"de_DE" use
"de"
407 information? What is the rule for locales composed of just an
408 ISO language code (say,
"de") and locales with both an ISO
409 language code and ISO country code (say,
"de_DE").
410 </p></li><li class=
"listitem"><p>
411 What should non-required facet instantiations do? If the
412 generic implementation is provided, then how to end-users
413 provide specializations?
414 </p></li></ul></div></div><div class=
"bibliography" title=
"Bibliography"><div class=
"titlepage"><div><div><h4 class=
"title"><a name=
"locales.locale.biblio"></a>Bibliography
</h4></div></div></div><div class=
"biblioentry"><a name=
"id624874"></a><p><span class=
"citetitle"><em class=
"citetitle">
416 </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">
417 Chapters
6 Character Set Handling and
7 Locales and
419 .
</span></p></div><div class=
"biblioentry"><a name=
"id624914"></a><p><span class=
"citetitle"><em class=
"citetitle">
421 </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 name=
"id624939"></a><p><span class=
"citetitle"><em class=
"citetitle">
422 ISO/IEC
14882:
1998 Programming languages - C++
423 </em>.
</span><span class=
"copyright">Copyright ©
1998 ISO.
</span></p></div><div class=
"biblioentry"><a name=
"id624958"></a><p><span class=
"citetitle"><em class=
"citetitle">
424 ISO/IEC
9899:
1999 Programming languages - C
425 </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 name=
"id624977"></a><p><span class=
"title"><i>
426 <a class=
"link" href=
"http://www.opengroup.org/austin/" target=
"_top">
427 System Interface Definitions, Issue
7 (IEEE Std.
1003.1-
2008)
429 </i>.
</span><span class=
"copyright">Copyright ©
2008
430 The Open Group/The Institute of Electrical and Electronics
432 .
</span></p></div><div class=
"biblioentry"><a name=
"id625004"></a><p><span class=
"citetitle"><em class=
"citetitle">
433 The C++ Programming Language, Special Edition
434 </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">
436 .
</span></span></p></div><div class=
"biblioentry"><a name=
"id625043"></a><p><span class=
"citetitle"><em class=
"citetitle">
437 Standard C++ IOStreams and Locales
438 </em>.
</span><span class=
"subtitle">
439 Advanced Programmer's Guide and Reference
440 .
</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">
441 Addison Wesley Longman
442 .
</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=
"bk01pt02.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.
445 </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>