1 <?xml version=
"1.0" encoding=
"ISO-8859-1"?>
3 PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
8 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1" />
9 <meta name=
"AUTHOR" content=
"bkoz@redhat.com (Benjamin Kosnik)" />
10 <meta name=
"KEYWORDS" content=
"HOWTO, libstdc++, locale name LC_ALL" />
11 <meta name=
"DESCRIPTION" content=
"Notes on the locale implementation." />
12 <title>Notes on the locale implementation.
</title>
13 <link rel=
"StyleSheet" href=
"../lib3styles.css" type=
"text/css" />
14 <link rel=
"Start" href=
"../documentation.html" type=
"text/html"
15 title=
"GNU C++ Standard Library" />
16 <link rel=
"Bookmark" href=
"howto.html" type=
"text/html" title=
"Localization" />
17 <link rel=
"Copyright" href=
"../17_intro/license.html" type=
"text/html" />
18 <link rel=
"Help" href=
"../faq/index.html" type=
"text/html" title=
"F.A.Q." />
22 Notes on the locale implementation.
25 prepared by Benjamin Kosnik (bkoz@redhat.com) on October
14,
2002
32 Describes the basic locale object, including nested
33 classes id, facet, and the reference-counted implementation object,
38 2. What the standard says
40 Class locale is non-templatized and has two distinct types nested
46 22.1.1.1.2 Class locale::facet
51 Facets actually implement locale functionality. For instance, a facet
52 called numpunct is the data objects that can be used to query for the
53 thousands separator is in the German locale.
56 Literally, a facet is strictly defined:
58 <li>containing the following public data member:
60 <code>static locale::id id;
</code>
64 <li>derived from another facet:
66 <code> class gnu_codecvt: public std::ctype
<user-defined-type
></code>
72 Of interest in this class are the memory management options explicitly
73 specified as an argument to facet's constructor. Each constructor of a
74 facet class takes a std::size_t __refs argument: if __refs ==
0, the
75 facet is deleted when the locale containing it is destroyed. If __refs
76 ==
1, the facet is not destroyed, even when it is no longer
83 22.1.1.1.3 - Class locale::id
88 Provides an index for looking up specific facets.
93 3. Interacting with
"C
" locales.
97 Some help on determining the underlying support for locales on a system.
98 Note, this is specific to linux (and glibc-
2.3.x)
102 <li> <code>`locale -a`
</code> displays available locales.
407 <li> <code>`locale`
</code> displays environmental variables
408 that impact how locale(
"") will be deduced.
423 LC_MEASUREMENT=
"en_US"
424 LC_IDENTIFICATION=
"en_US"
432 From Josuttis, p.
697-
698, which says, that
"there is only *one*
433 relation (of the C++ locale mechanism) to the C locale mechanism: the
434 global C locale is modified if a named C++ locale object is set as the
435 global locale" (emphasis Paolo), that is:
437 <code>std::locale::global(std::locale(
""));
</code>
439 <p>affects the C functions as if the following call was made:
</p>
441 <code>std::setlocale(LC_ALL,
"");
</code>
444 On the other hand, there is *no* viceversa, that is, calling setlocale
445 has *no* whatsoever on the C++ locale mechanism, in particular on the
446 working of locale(
""), which constructs the locale object from the
447 environment of the running program, that is, in practice, the set of
448 LC_ALL, LANG, etc. variable of the shell.
458 The major design challenge is fitting an object-orientated and
459 non-global locale design ontop of POSIX and other relevant stanards,
460 which include the Single Unix (nee X/Open.)
464 Because POSIX falls down so completely, portibility is an issue.
468 The internal representation of the std::locale object.
475 More information can be found in the following testcases:
477 <li> testsuite/
22_locale/all
</li>
485 <li> locale initialization: at what point does _S_classic,
486 _S_global get initialized? Can named locales assume this
487 initialization has already taken place?
</li>
489 <li> document how named locales error check when filling data
490 members. Ie, a fr_FR locale that doesn't have
491 numpunct::truename(): does it use
"true"? Or is it a blank
492 string? What's the convention?
</li>
494 <li> explain how locale aliasing happens. When does
"de_DE"
495 use
"de" information? What is the rule for locales composed of
496 just an ISO language code (say,
"de") and locales with both an
497 ISO language code and ISO country code (say,
"de_DE").
</li>
499 <li> what should non-required facet instantiations do? If the
500 generic implemenation is provided, then how to end-users
501 provide specializations?
</li>
509 8. Bibliography / Referenced Documents
512 Drepper, Ulrich, GNU libc (glibc)
2.2 manual. In particular, Chapters
"6. Character Set Handling
" and
"7 Locales and Internationalization
"
515 Drepper, Ulrich, Numerous, late-night email correspondence
519 ISO/IEC
14882:
1998 Programming languages - C++
523 ISO/IEC
9899:
1999 Programming languages - C
527 Langer, Angelika and Klaus Kreft, Standard C++ IOStreams and Locales, Advanced Programmer's Guide and Reference, Addison Wesley Longman, Inc.
2000
531 Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc.
2000
535 System Interface Definitions, Issue
6 (IEEE Std.
1003.1-
200x)
536 The Open Group/The Institute of Electrical and Electronics Engineers, Inc.
537 http://www.opennc.org/austin/docreg.html