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" />
17 Notes on the locale implementation.
20 prepared by Benjamin Kosnik (bkoz@redhat.com) on October
14,
2002
27 Describes the basic locale object, including nested
28 classes id, facet, and the reference-counted implementation object,
33 2. What the standard says
35 Class locale is non-templatized and has two distinct types nested
41 22.1.1.1.2 Class locale::facet
46 Facets actually implement locale functionality. For instance, a facet
47 called numpunct is the data objects that can be used to query for the
48 thousands separator is in the German locale.
51 Literally, a facet is strictly defined:
53 <li>containing the following public data member:
55 <code>static locale::id id;
</code>
59 <li>derived from another facet:
61 <code> class gnu_codecvt: public std::ctype
<user-defined-type
></code>
67 Of interest in this class are the memory management options explicitly
68 specified as an argument to facet's constructor. Each constructor of a
69 facet class takes a std::size_t __refs argument: if __refs ==
0, the
70 facet is deleted when the locale containing it is destroyed. If __refs
71 ==
1, the facet is not destroyed, even when it is no longer
78 22.1.1.1.3 - Class locale::id
83 Provides an index for looking up specific facets.
88 3. Interacting with
"C
" locales.
92 Some help on determining the underlying support for locales on a system.
93 Note, this is specific to linux (and glibc-
2.3.x)
97 <li> <code>`locale -a`
</code> displays available locales.
402 <li> <code>`locale`
</code> displays environmental variables
403 that impact how locale(
"") will be deduced.
418 LC_MEASUREMENT=
"en_US"
419 LC_IDENTIFICATION=
"en_US"
427 From Josuttis, p.
697-
698, which says, that
"there is only *one*
428 relation (of the C++ locale mechanism) to the C locale mechanism: the
429 global C locale is modified if a named C++ locale object is set as the
430 global locale" (emphasis Paolo), that is:
432 <code>std::locale::global(std::locale(
""));
</code>
434 <p>affects the C functions as if the following call was made:
</p>
436 <code>std::setlocale(LC_ALL,
"");
</code>
439 On the other hand, there is *no* viceversa, that is, calling setlocale
440 has *no* whatsoever on the C++ locale mechanism, in particular on the
441 working of locale(
""), which constructs the locale object from the
442 environment of the running program, that is, in practice, the set of
443 LC_ALL, LANG, etc. variable of the shell.
453 The major design challenge is fitting an object-orientated and
454 non-global locale design ontop of POSIX and other relevant stanards,
455 which include the Single Unix (nee X/Open.)
459 Because POSIX falls down so completely, portibility is an issue.
463 The internal representation of the std::locale object.
470 More information can be found in the following testcases:
472 <li> testsuite/
22_locale/all
</li>
480 <li> locale initialization: at what point does _S_classic,
481 _S_global get initialized? Can named locales assume this
482 initialization has already taken place?
</li>
484 <li> document how named locales error check when filling data
485 members. Ie, a fr_FR locale that doesn't have
486 numpunct::truename(): does it use
"true"? Or is it a blank
487 string? What's the convention?
</li>
489 <li> explain how locale aliasing happens. When does
"de_DE"
490 use
"de" information? What is the rule for locales composed of
491 just an ISO language code (say,
"de") and locales with both an
492 ISO language code and ISO country code (say,
"de_DE").
</li>
494 <li> what should non-required facet instantiations do? If the
495 generic implemenation is provided, then how to end-users
496 provide specializations?
</li>
504 8. Bibliography / Referenced Documents
507 Drepper, Ulrich, GNU libc (glibc)
2.2 manual. In particular, Chapters
"6. Character Set Handling
" and
"7 Locales and Internationalization
"
510 Drepper, Ulrich, Numerous, late-night email correspondence
514 ISO/IEC
14882:
1998 Programming languages - C++
518 ISO/IEC
9899:
1999 Programming languages - C
522 Langer, Angelika and Klaus Kreft, Standard C++ IOStreams and Locales, Advanced Programmer's Guide and Reference, Addison Wesley Longman, Inc.
2000
526 Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc.
2000
530 System Interface Definitions, Issue
6 (IEEE Std.
1003.1-
200x)
531 The Open Group/The Institute of Electrical and Electronics Engineers, Inc.
532 http://www.opennc.org/austin/docreg.html