2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / docs / html / 22_locale / ctype.html
blobee5e69f7cf786a0eaa4de0b99a4e8870a4148006
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">
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
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++, GCC, g++, libg++, STL" />
11 <meta name="DESCRIPTION" content="Notes on the ctype implementation." />
12 <title>Notes on the ctype 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." />
19 </head>
20 <body>
21 <h1>
22 Notes on the ctype implementation.
23 </h1>
24 <em>
25 prepared by Benjamin Kosnik (bkoz@redhat.com) on August 30, 2000
26 </em>
28 <h2>
29 1. Abstract
30 </h2>
31 <p>
32 Woe is me.
33 </p>
35 <h2>
36 2. What the standard says
37 </h2>
40 <h2>
41 3. Problems with &quot;C&quot; ctype : global locales, termination.
42 </h2>
44 <p>
45 For the required specialization codecvt&lt;wchar_t, char, mbstate_t&gt; ,
46 conversions are made between the internal character set (always UCS4
47 on GNU/Linux) and whatever the currently selected locale for the
48 LC_CTYPE category implements.
49 </p>
51 <h2>
52 4. Design
53 </h2>
54 The two required specializations are implemented as follows:
56 <p>
57 <code>
58 ctype&lt;char&gt;
59 </code>
60 </p>
61 <p>
62 This is simple specialization. Implementing this was a piece of cake.
63 </p>
65 <p>
66 <code>
67 ctype&lt;wchar_t&gt;
68 </code>
69 </p>
70 <p>
71 This specialization, by specifying all the template parameters, pretty
72 much ties the hands of implementors. As such, the implementation is
73 straightforward, involving mcsrtombs for the conversions between char
74 to wchar_t and wcsrtombs for conversions between wchar_t and char.
75 </p>
77 <p>
78 Neither of these two required specializations deals with Unicode
79 characters. As such, libstdc++-v3 implements
80 </p>
82 <h2>
83 5. Examples
84 </h2>
86 <pre>
87 typedef ctype&lt;char&gt; cctype;
88 </pre>
90 More information can be found in the following testcases:
91 <ul>
92 <li> testsuite/22_locale/ctype_char_members.cc </li>
93 <li> testsuite/22_locale/ctype_wchar_t_members.cc </li>
94 </ul>
96 <h2>
97 6. Unresolved Issues
98 </h2>
100 <ul>
101 <li> how to deal with the global locale issue? </li>
103 <li> how to deal with different types than char, wchar_t? </li>
105 <li> codecvt/ctype overlap: narrow/widen </li>
107 <li> mask typedef in codecvt_base, argument types in codecvt.
108 what is know about this type? </li>
110 <li> why mask* argument in codecvt? </li>
112 <li> can this be made (more) generic? is there a simple way to
113 straighten out the configure-time mess that is a by-product of
114 this class? </li>
116 <li> get the ctype&lt;wchar_t&gt;::mask stuff under control. Need to
117 make some kind of static table, and not do lookup evertime
118 somebody hits the do_is... functions. Too bad we can't just
119 redefine mask for ctype&lt;wchar_t&gt; </li>
121 <li> rename abstract base class. See if just smash-overriding
122 is a better approach. Clarify, add sanity to naming. </li>
124 </ul>
127 <h2>
128 7. Acknowledgments
129 </h2>
130 Ulrich Drepper for patient answering of late-night questions, skeletal
131 examples, and C language expertise.
133 <h2>
134 8. Bibliography / Referenced Documents
135 </h2>
137 Drepper, Ulrich, GNU libc (glibc) 2.2 manual. In particular, Chapters &quot;6. Character Set Handling&quot; and &quot;7 Locales and Internationalization&quot;
140 Drepper, Ulrich, Numerous, late-night email correspondence
141 </p>
144 ISO/IEC 14882:1998 Programming languages - C++
145 </p>
148 ISO/IEC 9899:1999 Programming languages - C
149 </p>
152 Langer, Angelika and Klaus Kreft, Standard C++ IOStreams and Locales, Advanced Programmer's Guide and Reference, Addison Wesley Longman, Inc. 2000
153 </p>
156 Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc. 2000
157 </p>
160 System Interface Definitions, Issue 6 (IEEE Std. 1003.1-200x)
161 The Open Group/The Institute of Electrical and Electronics Engineers, Inc.
162 http://www.opennc.org/austin/docreg.html
163 </p>
165 </body>
166 </html>