2.5-18.1
[glibc.git] / wctype / wctype.h
blob5bfe43895c5e03f42c0bf81d40c3383a6b03a84e
1 /* Copyright (C) 1996-2002, 2005 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
20 * ISO C99 Standard: 7.25
21 * Wide character classification and mapping utilities <wctype.h>
24 #ifndef _WCTYPE_H
26 #include <features.h>
27 #include <bits/types.h>
29 #ifndef __need_iswxxx
30 # define _WCTYPE_H 1
32 /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
33 there. So define it ourselves if it remains undefined. */
34 # define __need_wint_t
35 # include <stddef.h>
36 # ifndef _WINT_T
37 /* Integral type unchanged by default argument promotions that can
38 hold any value corresponding to members of the extended character
39 set, as well as at least one value that does not correspond to any
40 member of the extended character set. */
41 # define _WINT_T
42 typedef unsigned int wint_t;
43 # else
44 # ifdef __USE_ISOC99
45 __USING_NAMESPACE_C99(wint_t)
46 # endif
47 # endif
49 /* Constant expression of type `wint_t' whose value does not correspond
50 to any member of the extended character set. */
51 # ifndef WEOF
52 # define WEOF (0xffffffffu)
53 # endif
54 #endif
55 #undef __need_iswxxx
58 /* The following part is also used in the <wcsmbs.h> header when compiled
59 in the Unix98 compatibility mode. */
60 #ifndef __iswxxx_defined
61 # define __iswxxx_defined 1
63 __BEGIN_NAMESPACE_C99
64 /* Scalar type that can hold values which represent locale-specific
65 character classifications. */
66 typedef unsigned long int wctype_t;
67 __END_NAMESPACE_C99
69 # ifndef _ISwbit
70 /* The characteristics are stored always in network byte order (big
71 endian). We define the bit value interpretations here dependent on the
72 machine's byte order. */
74 # include <endian.h>
75 # if __BYTE_ORDER == __BIG_ENDIAN
76 # define _ISwbit(bit) (1 << (bit))
77 # else /* __BYTE_ORDER == __LITTLE_ENDIAN */
78 # define _ISwbit(bit) \
79 ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \
80 : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \
81 : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \
82 : (int) ((1UL << (bit)) >> 24))))
83 # endif
85 enum
87 __ISwupper = 0, /* UPPERCASE. */
88 __ISwlower = 1, /* lowercase. */
89 __ISwalpha = 2, /* Alphabetic. */
90 __ISwdigit = 3, /* Numeric. */
91 __ISwxdigit = 4, /* Hexadecimal numeric. */
92 __ISwspace = 5, /* Whitespace. */
93 __ISwprint = 6, /* Printing. */
94 __ISwgraph = 7, /* Graphical. */
95 __ISwblank = 8, /* Blank (usually SPC and TAB). */
96 __ISwcntrl = 9, /* Control character. */
97 __ISwpunct = 10, /* Punctuation. */
98 __ISwalnum = 11, /* Alphanumeric. */
100 _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */
101 _ISwlower = _ISwbit (__ISwlower), /* lowercase. */
102 _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */
103 _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */
104 _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */
105 _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */
106 _ISwprint = _ISwbit (__ISwprint), /* Printing. */
107 _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */
108 _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */
109 _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */
110 _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */
111 _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */
113 # endif /* Not _ISwbit */
116 __BEGIN_DECLS
118 __BEGIN_NAMESPACE_C99
120 * Wide-character classification functions: 7.15.2.1.
123 /* Test for any wide character for which `iswalpha' or `iswdigit' is
124 true. */
125 extern int iswalnum (wint_t __wc) __THROW;
127 /* Test for any wide character for which `iswupper' or 'iswlower' is
128 true, or any wide character that is one of a locale-specific set of
129 wide-characters for which none of `iswcntrl', `iswdigit',
130 `iswpunct', or `iswspace' is true. */
131 extern int iswalpha (wint_t __wc) __THROW;
133 /* Test for any control wide character. */
134 extern int iswcntrl (wint_t __wc) __THROW;
136 /* Test for any wide character that corresponds to a decimal-digit
137 character. */
138 extern int iswdigit (wint_t __wc) __THROW;
140 /* Test for any wide character for which `iswprint' is true and
141 `iswspace' is false. */
142 extern int iswgraph (wint_t __wc) __THROW;
144 /* Test for any wide character that corresponds to a lowercase letter
145 or is one of a locale-specific set of wide characters for which
146 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
147 extern int iswlower (wint_t __wc) __THROW;
149 /* Test for any printing wide character. */
150 extern int iswprint (wint_t __wc) __THROW;
152 /* Test for any printing wide character that is one of a
153 locale-specific et of wide characters for which neither `iswspace'
154 nor `iswalnum' is true. */
155 extern int iswpunct (wint_t __wc) __THROW;
157 /* Test for any wide character that corresponds to a locale-specific
158 set of wide characters for which none of `iswalnum', `iswgraph', or
159 `iswpunct' is true. */
160 extern int iswspace (wint_t __wc) __THROW;
162 /* Test for any wide character that corresponds to an uppercase letter
163 or is one of a locale-specific set of wide character for which none
164 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
165 extern int iswupper (wint_t __wc) __THROW;
167 /* Test for any wide character that corresponds to a hexadecimal-digit
168 character equivalent to that performed be the functions described
169 in the previous subclause. */
170 extern int iswxdigit (wint_t __wc) __THROW;
172 /* Test for any wide character that corresponds to a standard blank
173 wide character or a locale-specific set of wide characters for
174 which `iswalnum' is false. */
175 # ifdef __USE_ISOC99
176 extern int iswblank (wint_t __wc) __THROW;
177 # endif
180 * Extensible wide-character classification functions: 7.15.2.2.
183 /* Construct value that describes a class of wide characters identified
184 by the string argument PROPERTY. */
185 extern wctype_t wctype (__const char *__property) __THROW;
187 /* Determine whether the wide-character WC has the property described by
188 DESC. */
189 extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
190 __END_NAMESPACE_C99
194 * Wide-character case-mapping functions: 7.15.3.1.
197 __BEGIN_NAMESPACE_C99
198 /* Scalar type that can hold values which represent locale-specific
199 character mappings. */
200 typedef __const __int32_t *wctrans_t;
201 __END_NAMESPACE_C99
202 #ifdef __USE_GNU
203 __USING_NAMESPACE_C99(wctrans_t)
204 #endif
206 __BEGIN_NAMESPACE_C99
207 /* Converts an uppercase letter to the corresponding lowercase letter. */
208 extern wint_t towlower (wint_t __wc) __THROW;
210 /* Converts an lowercase letter to the corresponding uppercase letter. */
211 extern wint_t towupper (wint_t __wc) __THROW;
212 __END_NAMESPACE_C99
214 __END_DECLS
216 #endif /* need iswxxx. */
219 /* The remaining definitions and declarations must not appear in the
220 <wcsmbs.h> header. */
221 #ifdef _WCTYPE_H
224 * Extensible wide-character mapping functions: 7.15.3.2.
227 __BEGIN_DECLS
229 __BEGIN_NAMESPACE_C99
230 /* Construct value that describes a mapping between wide characters
231 identified by the string argument PROPERTY. */
232 extern wctrans_t wctrans (__const char *__property) __THROW;
234 /* Map the wide character WC using the mapping described by DESC. */
235 extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
236 __END_NAMESPACE_C99
238 # ifdef __USE_GNU
239 /* Declare the interface to extended locale model. */
240 # include <xlocale.h>
242 /* Test for any wide character for which `iswalpha' or `iswdigit' is
243 true. */
244 extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW;
246 /* Test for any wide character for which `iswupper' or 'iswlower' is
247 true, or any wide character that is one of a locale-specific set of
248 wide-characters for which none of `iswcntrl', `iswdigit',
249 `iswpunct', or `iswspace' is true. */
250 extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW;
252 /* Test for any control wide character. */
253 extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW;
255 /* Test for any wide character that corresponds to a decimal-digit
256 character. */
257 extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW;
259 /* Test for any wide character for which `iswprint' is true and
260 `iswspace' is false. */
261 extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW;
263 /* Test for any wide character that corresponds to a lowercase letter
264 or is one of a locale-specific set of wide characters for which
265 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
266 extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW;
268 /* Test for any printing wide character. */
269 extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW;
271 /* Test for any printing wide character that is one of a
272 locale-specific et of wide characters for which neither `iswspace'
273 nor `iswalnum' is true. */
274 extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
276 /* Test for any wide character that corresponds to a locale-specific
277 set of wide characters for which none of `iswalnum', `iswgraph', or
278 `iswpunct' is true. */
279 extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
281 /* Test for any wide character that corresponds to an uppercase letter
282 or is one of a locale-specific set of wide character for which none
283 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
284 extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW;
286 /* Test for any wide character that corresponds to a hexadecimal-digit
287 character equivalent to that performed be the functions described
288 in the previous subclause. */
289 extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW;
291 /* Test for any wide character that corresponds to a standard blank
292 wide character or a locale-specific set of wide characters for
293 which `iswalnum' is false. */
294 extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
296 /* Construct value that describes a class of wide characters identified
297 by the string argument PROPERTY. */
298 extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
299 __THROW;
301 /* Determine whether the wide-character WC has the property described by
302 DESC. */
303 extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
304 __THROW;
308 * Wide-character case-mapping functions.
311 /* Converts an uppercase letter to the corresponding lowercase letter. */
312 extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW;
314 /* Converts an lowercase letter to the corresponding uppercase letter. */
315 extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW;
317 /* Construct value that describes a mapping between wide characters
318 identified by the string argument PROPERTY. */
319 extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale)
320 __THROW;
322 /* Map the wide character WC using the mapping described by DESC. */
323 extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
324 __locale_t __locale) __THROW;
326 # endif /* Use GNU. */
328 __END_DECLS
330 #endif /* __WCTYPE_H defined. */
332 #endif /* wctype.h */