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-NS Stylesheets V1.78.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=
"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.
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.
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.
9 <a id=
"idm269891625280" 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#idm269891548288">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"><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>
11 Describes the basic locale object, including nested
12 classes id, facet, and the reference-counted implementation object,
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>
15 Class locale is non-templatized and has two distinct types nested
17 </p><div class=
"blockquote"><blockquote class=
"blockquote"><p>
18 <span class=
"emphasis"><em>
20 22.1.1.1.2 Class locale::facet
22 </p></blockquote></div><p>
23 Facets actually implement locale functionality. For instance, a facet
24 called numpunct is the data object that can be used to query for the
25 thousands separator in the locale.
27 Literally, 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:
31 <code class=
"code">static locale::id id;
</code>
32 </p></li><li class=
"listitem"><p>
33 Derived from another facet:
35 <code class=
"code">class gnu_codecvt: public std::ctype
<user-defined-type
></code>
36 </p></li></ul></div><p>
37 Of interest in this class are the memory management options explicitly
38 specified as an argument to facet's constructor. Each constructor of a
39 facet class takes a std::size_t __refs argument: if __refs ==
0, the
40 facet is deleted when the locale containing it is destroyed. If __refs
41 ==
1, the facet is not destroyed, even when it is no longer
43 </p><div class=
"blockquote"><blockquote class=
"blockquote"><p>
44 <span class=
"emphasis"><em>
46 22.1.1.1.3 - Class locale::id
48 </p></blockquote></div><p>
49 Provides 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>
51 The major design challenge is fitting an object-orientated and
52 non-global locale design on top of POSIX and other relevant standards,
53 which include the Single Unix (nee X/Open.)
55 Because C and earlier versions of POSIX fall down so completely,
56 portability 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">
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">
373 LC_MEASUREMENT=
"en_US"
374 LC_IDENTIFICATION=
"en_US"
376 </pre></blockquote></div></li></ul></div><p>
377 From Josuttis, p.
697-
698, which says, that
"there is only *one*
378 relation (of the C++ locale mechanism) to the C locale mechanism: the
379 global C locale is modified if a named C++ locale object is set as the
380 global 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=
"idm269891582432"></a><p><span class=
"citetitle"><em class=
"citetitle">
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
410 .
</span></p></div><div class=
"biblioentry"><a id=
"idm269891577664"></a><p><span class=
"citetitle"><em class=
"citetitle">
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=
"idm269891574576"></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=
"idm269891572288"></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=
"idm269891570016"></a><p><span class=
"title"><em>
417 <a class=
"link" href=
"http://www.opengroup.org/austin/" target=
"_top">
418 System Interface Definitions, Issue
7 (IEEE Std.
1003.1-
2008)
420 </em>.
</span><span class=
"copyright">Copyright ©
2008
421 The Open Group/The Institute of Electrical and Electronics
423 .
</span></p></div><div class=
"biblioentry"><a id=
"idm269891566784"></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">
427 .
</span></span></p></div><div class=
"biblioentry"><a id=
"idm269891562160"></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.
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>