OSDN Git Service

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