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>
20prepared by Benjamin Kosnik (bkoz@redhat.com) on August 30, 2000
21</em>
22
23<h2>
241. Abstract
25</h2>
26<p>
27Woe is me.
28</p>
29
30<h2>
312. What the standard says
32</h2>
33
34
35<h2>
363. Problems with &quot;C&quot; ctype : global locales, termination.
37</h2>
38
39<p>
40For the required specialization codecvt&lt;wchar_t, char, mbstate_t&gt; ,
41conversions are made between the internal character set (always UCS4
42on GNU/Linux) and whatever the currently selected locale for the
43LC_CTYPE category implements.
44</p>
45
46<h2>
474. Design
48</h2>
49The two required specializations are implemented as follows:
50
51<p>
52<code>
53ctype&lt;char&gt;
54</code>
55</p>
56<p>
57This is simple specialization. Implementing this was a piece of cake.
58</p>
59
60<p>
61<code>
62ctype&lt;wchar_t&gt;
63</code>
64</p>
65<p>
66This specialization, by specifying all the template parameters, pretty
67much ties the hands of implementors. As such, the implementation is
68straightforward, involving mcsrtombs for the conversions between char
69to wchar_t and wcsrtombs for conversions between wchar_t and char.
70</p>
71
72<p>
73Neither of these two required specializations deals with Unicode
74characters. As such, libstdc++-v3 implements 
75</p>
76
77<h2>
785.  Examples
79</h2>
80
81<pre>
82  typedef ctype&lt;char&gt; cctype;
83</pre>
84
85More 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>
926.  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>
1237. Acknowledgments
124</h2>
125Ulrich Drepper for patient answering of late-night questions, skeletal
126examples, and C language expertise.
127
128<h2>
1298. Bibliography / Referenced Documents
130</h2>
131
132Drepper, 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>
135Drepper, Ulrich, Numerous, late-night email correspondence
136</p>
137
138<p>
139ISO/IEC 14882:1998 Programming languages - C++
140</p>
141
142<p>
143ISO/IEC 9899:1999 Programming languages - C
144</p>
145
146<p>
147Langer, 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>
151Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc. 2000
152</p>
153
154<p>
155System Interface Definitions, Issue 6 (IEEE Std. 1003.1-200x)
156The Open Group/The Institute of Electrical and Electronics Engineers, Inc.
157http://www.opennc.org/austin/docreg.html
158</p>
159
160</body>
161</html>
162