]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/docs/html/22_locale/locale.html
localefwd.h (class locale): Add static member _S_num_extra_categories...
[thirdparty/gcc.git] / libstdc++-v3 / docs / html / 22_locale / locale.html
CommitLineData
ba43f4eb
JW
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE html
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
5d5e5e4e 6<head>
64a6f971
JW
7 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
8 <meta name="AUTHOR" content="bkoz@redhat.com (Benjamin Kosnik)" />
9 <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL" />
10 <meta name="DESCRIPTION" content="Notes on the locale implementation." />
11 <title>Notes on the locale implementation.</title>
12<link rel="StyleSheet" href="../lib3styles.css" />
1860e6ab
JW
13</head>
14<body>
5d5e5e4e 15 <h1>
04807c28 16 Notes on the locale implementation.
5d5e5e4e 17 </h1>
64a6f971 18<em>
33590f13 19prepared by Benjamin Kosnik (bkoz@redhat.com) on August 8, 2001
64a6f971 20</em>
04807c28 21
5d5e5e4e 22<h2>
0214010c
BK
231. Abstract Describes the basic locale object, including nested
24classes id, facet, and the reference-counted implementation object,
25class _Impl.
5d5e5e4e
PE
26</h2>
27<p>
28</p>
04807c28 29
5d5e5e4e 30<h2>
04807c28 312. What the standard says
5d5e5e4e 32</h2>
64a6f971 33See Chapter 22 of the standard.
04807c28
BK
34
35
5d5e5e4e 36<h2>
04807c28 373. Problems with &quot;C&quot; locales : global locales, termination.
5d5e5e4e 38</h2>
04807c28 39
5d5e5e4e 40<p>
0214010c
BK
41The major problem is fitting an object-orientated and non-global locale
42design ontop of POSIX and other relevant stanards, which include the
43Single Unix (nee X/Open.)
04807c28 44
0214010c 45Because POSIX falls down so completely, portibility is an issue.
64a6f971 46</p>
0214010c 47
5d5e5e4e 48<h2>
04807c28 494. Design
5d5e5e4e 50</h2>
0214010c
BK
51Class locale in non-templatized and has three distinct types nested
52inside of it:
53
54class facet
5522.1.1.1.2 Class locale::facet
56
57Facets actually implement locale functionality. For instance, a facet
58called numpunct is the data objects that can be used to query for the
cc712abf 59thousands separator is in the German locale.
0214010c
BK
60
61Literally, a facet is strictly defined:
62 - containing
63public:
64 static locale::id id;
65
66- or derived from another facet
67
68The only other thing of interest in this class is the memory
69management of facets. Each constructor of a facet class takes a
70std::size_t __refs argument: if __refs == 0, the facet is deleted when
aa53f832
PC
71the locale containing it is destroyed. If __refs == 1, the facet is
72not destroyed, even when it is no longer referenced.
0214010c
BK
73
74
75class id
76Provides an index for looking up specific facets.
04807c28 77
0214010c 78class _Impl
aa53f832
PC
79The internal representation of the std::locale object.
80
81<h2>
825. Relationship to traditional "C" locales.
83</h2>
84
85From Josuttis, p. 697-698, which says, that "there is only *one*
86relation (of the C++ locale mechanism) to the C locale mechanism: the
87global C locale is modified if a named C++ locale object is set as the
88global locale" (emphasis Paolo), that is:
89
90 std::locale::global(std::locale(""));
91
92affects the C functions as if the following call was made:
93
94 std::setlocale(LC_ALL, "");
95
96On the other hand, there is *no* viceversa, that is, calling setlocale
97has *no* whatsoever on the C++ locale mechanism, in particular on the
98working of locale(""), which constructs the locale object from the
99environment of the running program, that is, in practice, the set of
100LC_ALL, LANG, etc. variable of the shell.
04807c28 101
5d5e5e4e 102<h2>
04807c28 1035. Examples
5d5e5e4e 104</h2>
04807c28
BK
105
106<pre>
0214010c 107 typedef __locale_t locale;
04807c28
BK
108</pre>
109
110More information can be found in the following testcases:
5d5e5e4e 111<ul>
aa53f832 112<li> testsuite/22_locale/all </li>
5d5e5e4e 113</ul>
04807c28 114
5d5e5e4e 115<h2>
04807c28 1166. Unresolved Issues
5d5e5e4e 117</h2>
04807c28 118
5d5e5e4e 119<ul>
64a6f971 120 <li> locale -a displays available locales on linux </li>
04807c28 121
64a6f971
JW
122 <li> locale initialization: at what point does _S_classic,
123 _S_global get initialized? Can named locales assume this
124 initialization has already taken place? </li>
33590f13 125
64a6f971
JW
126 <li> document how named locales error check when filling data
127 members. Ie, a fr_FR locale that doesn't have
128 numpunct::truename(): does it use "true"? Or is it a blank
129 string? What's the convention? </li>
33590f13 130
64a6f971
JW
131 <li> explain how locale aliasing happens. When does "de_DE"
132 use "de" information? What is the rule for locales composed of
133 just an ISO language code (say, "de") and locales with both an
134 ISO language code and ISO country code (say, "de_DE"). </li>
04807c28 135
64a6f971
JW
136 <li> what should non-required facet instantiations do? If the
137 generic implemenation is provided, then how to end-users
138 provide specializations? </li>
e08138aa 139</ul>
04807c28 140
5d5e5e4e 141<h2>
04807c28 1427. Acknowledgments
5d5e5e4e 143</h2>
04807c28 144
5d5e5e4e 145<h2>
04807c28 1468. Bibliography / Referenced Documents
5d5e5e4e 147</h2>
04807c28
BK
148
149Drepper, Ulrich, GNU libc (glibc) 2.2 manual. In particular, Chapters &quot;6. Character Set Handling&quot; and &quot;7 Locales and Internationalization&quot;
150
5d5e5e4e 151<p>
04807c28 152Drepper, Ulrich, Numerous, late-night email correspondence
64a6f971 153</p>
04807c28 154
5d5e5e4e 155<p>
04807c28 156ISO/IEC 14882:1998 Programming languages - C++
64a6f971 157</p>
04807c28 158
5d5e5e4e 159<p>
04807c28 160ISO/IEC 9899:1999 Programming languages - C
64a6f971 161</p>
04807c28 162
5d5e5e4e 163<p>
04807c28 164Langer, Angelika and Klaus Kreft, Standard C++ IOStreams and Locales, Advanced Programmer's Guide and Reference, Addison Wesley Longman, Inc. 2000
64a6f971 165</p>
04807c28 166
5d5e5e4e 167<p>
04807c28 168Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc. 2000
64a6f971 169</p>
04807c28 170
5d5e5e4e 171<p>
04807c28
BK
172System Interface Definitions, Issue 6 (IEEE Std. 1003.1-200x)
173The Open Group/The Institute of Electrical and Electronics Engineers, Inc.
174http://www.opennc.org/austin/docreg.html
64a6f971
JW
175</p>
176
177</body>
178</html>
179
180