1 /* Copyright (C) 1996, 1997, 1998 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 Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 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 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C Standard, Amendment 1, 7.15:
21 * Wide-character classification and mapping utilities <wctype.h>
29 # include <features.h>
30 # include <bits/types.h>
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
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. */
42 typedef unsigned int wint_t;
45 /* Constant expression of type `wint_t' whose value does not correspond
46 to any member of the extended character set. */
48 # define WEOF (0xffffffffu)
54 /* The following part is also used in the <wcsmbs.h> header when compiled
55 in the Unix98 compatibility mode. */
56 #ifndef __iswxxx_defined
57 # define __iswxxx_defined 1
59 /* Scalar type that can hold values which represent locale-specific
60 character classifications. */
61 typedef unsigned long int wctype_t;
64 /* The characteristics are stored always in network byte order (big
65 endian). We define the bit value interpretations here dependent on the
66 machine's byte order. */
69 # if __BYTE_ORDER == __BIG_ENDIAN
70 # define _ISwbit(bit) (1 << (bit))
71 # else /* __BYTE_ORDER == __LITTLE_ENDIAN */
72 # define _ISwbit(bit) ((bit) < 8 ? 1UL << (bit) << 24 : 1UL << ((bit) + 8))
77 _ISwupper
= _ISwbit (0), /* UPPERCASE. */
78 _ISwlower
= _ISwbit (1), /* lowercase. */
79 _ISwalpha
= _ISwbit (2), /* Alphabetic. */
80 _ISwdigit
= _ISwbit (3), /* Numeric. */
81 _ISwxdigit
= _ISwbit (4), /* Hexadecimal numeric. */
82 _ISwspace
= _ISwbit (5), /* Whitespace. */
83 _ISwprint
= _ISwbit (6), /* Printing. */
84 _ISwgraph
= _ISwbit (7), /* Graphical. */
85 _ISwblank
= _ISwbit (8), /* Blank (usually SPC and TAB). */
86 _ISwcntrl
= _ISwbit (9), /* Control character. */
87 _ISwpunct
= _ISwbit (10), /* Punctuation. */
88 _ISwalnum
= _ISwbit (11) /* Alphanumeric. */
90 # endif /* Not _ISwbit */
96 * Wide-character classification functions: 7.15.2.1.
99 /* Test for any wide character for which `iswalpha' or `iswdigit' is
101 extern int iswalnum
__P ((wint_t __wc
));
103 /* Test for any wide character for which `iswupper' or 'iswlower' is
104 true, or any wide character that is one of a locale-specific set of
105 wide-characters for which none of `iswcntrl', `iswdigit',
106 `iswpunct', or `iswspace' is true. */
107 extern int iswalpha
__P ((wint_t __wc
));
109 /* Test for any control wide character. */
110 extern int iswcntrl
__P ((wint_t __wc
));
112 /* Test for any wide character that corresponds to a decimal-digit
114 extern int iswdigit
__P ((wint_t __wc
));
116 /* Test for any wide character for which `iswprint' is true and
117 `iswspace' is false. */
118 extern int iswgraph
__P ((wint_t __wc
));
120 /* Test for any wide character that corresponds to a lowercase letter
121 or is one of a locale-specific set of wide characters for which
122 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
123 extern int iswlower
__P ((wint_t __wc
));
125 /* Test for any printing wide character. */
126 extern int iswprint
__P ((wint_t __wc
));
128 /* Test for any printing wide character that is one of a
129 locale-specific et of wide characters for which neither `iswspace'
130 nor `iswalnum' is true. */
131 extern int iswpunct
__P ((wint_t __wc
));
133 /* Test for any wide character that corresponds to a locale-specific
134 set of wide characters for which none of `iswalnum', `iswgraph', or
135 `iswpunct' is true. */
136 extern int iswspace
__P ((wint_t __wc
));
138 /* Test for any wide character that corresponds to an uppercase letter
139 or is one of a locale-specific set of wide character for which none
140 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
141 extern int iswupper
__P ((wint_t __wc
));
143 /* Test for any wide character that corresponds to a hexadecimal-digit
144 character equivalent to that performed be the functions described
145 in the previous subclause. */
146 extern int iswxdigit
__P ((wint_t __wc
));
148 /* Test for any wide character that corresponds to a standard blank
149 wide character or a locale-specific set of wide characters for
150 which `iswalnum' is false. */
152 extern int iswblank
__P ((wint_t __wc
));
156 * Extensible wide-character classification functions: 7.15.2.2.
159 /* Construct value that describes a class of wide characters identified
160 by the string argument PROPERTY. */
161 extern wctype_t __wctype
__P ((__const
char *__property
));
162 extern wctype_t wctype
__P ((__const
char *__property
));
164 /* Determine whether the wide-character WC has the property described by
166 extern int __iswctype
__P ((wint_t __wc
, wctype_t __desc
));
167 extern int iswctype
__P ((wint_t __wc
, wctype_t __desc
));
171 * Wide-character case-mapping functions: 7.15.3.1.
174 /* Scalar type that can hold values which represent locale-specific
175 character mappings. */
176 typedef __const __int32_t
*wctrans_t;
178 /* Converts an uppercase letter to the corresponding lowercase letter. */
179 extern wint_t towlower
__P ((wint_t __wc
));
181 /* Converts an lowercase letter to the corresponding uppercase letter. */
182 extern wint_t towupper
__P ((wint_t __wc
));
184 /* Map the wide character WC using the mapping described by DESC. */
185 extern wint_t __towctrans
__P ((wint_t __wc
, wctrans_t __desc
));
189 # define iswalnum(wc) __iswctype ((wc), _ISwalnum)
190 # define iswalpha(wc) __iswctype ((wc), _ISwalpha)
191 # define iswcntrl(wc) __iswctype ((wc), _ISwcntrl)
192 # define iswdigit(wc) __iswctype ((wc), _ISwdigit)
193 # define iswlower(wc) __iswctype ((wc), _ISwlower)
194 # define iswgraph(wc) __iswctype ((wc), _ISwgraph)
195 # define iswprint(wc) __iswctype ((wc), _ISwprint)
196 # define iswpunct(wc) __iswctype ((wc), _ISwpunct)
197 # define iswspace(wc) __iswctype ((wc), _ISwspace)
198 # define iswupper(wc) __iswctype ((wc), _ISwupper)
199 # define iswxdigit(wc) __iswctype ((wc), _ISwxdigit)
202 # define iswblank(wc) __iswctype ((wc), _ISwblank)
206 /* Pointer to conversion tables. */
207 extern __const __int32_t
*__ctype_tolower
; /* Case conversions. */
208 extern __const __int32_t
*__ctype_toupper
; /* Case conversions. */
210 # define towlower(wc) __towctrans ((wc), __ctype_tolower)
211 # define towupper(wc) __towctrans ((wc), __ctype_toupper)
213 # endif /* Not __NO_WCTYPE. */
217 #endif /* need iswxxx. */
220 /* The remaining definitions and declarations must not appear in the
221 <wcsmbs.h> header. */
225 * Extensible wide-character mapping functions: 7.15.3.2.
230 /* Construct value that describes a mapping between wide characters
231 identified by the string argument PROPERTY. */
232 extern wctrans_t wctrans
__P ((__const
char *__property
));
234 /* Map the wide character WC using the mapping described by DESC. */
235 extern wint_t towctrans
__P ((wint_t __wc
, wctrans_t __desc
));
238 /* Declare the interface to extended locale model. */
239 # include <xlocale.h>
241 /* Test for any wide character for which `iswalpha' or `iswdigit' is
243 extern int __iswalnum_l
__P ((wint_t __wc
, __locale_t __locale
));
245 /* Test for any wide character for which `iswupper' or 'iswlower' is
246 true, or any wide character that is one of a locale-specific set of
247 wide-characters for which none of `iswcntrl', `iswdigit',
248 `iswpunct', or `iswspace' is true. */
249 extern int __iswalpha_l
__P ((wint_t __wc
, __locale_t __locale
));
251 /* Test for any control wide character. */
252 extern int __iswcntrl_l
__P ((wint_t __wc
, __locale_t __locale
));
254 /* Test for any wide character that corresponds to a decimal-digit
256 extern int __iswdigit_l
__P ((wint_t __wc
, __locale_t __locale
));
258 /* Test for any wide character for which `iswprint' is true and
259 `iswspace' is false. */
260 extern int __iswgraph_l
__P ((wint_t __wc
, __locale_t __locale
));
262 /* Test for any wide character that corresponds to a lowercase letter
263 or is one of a locale-specific set of wide characters for which
264 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
265 extern int __iswlower_l
__P ((wint_t __wc
, __locale_t __locale
));
267 /* Test for any printing wide character. */
268 extern int __iswprint_l
__P ((wint_t __wc
, __locale_t __locale
));
270 /* Test for any printing wide character that is one of a
271 locale-specific et of wide characters for which neither `iswspace'
272 nor `iswalnum' is true. */
273 extern int __iswpunct_l
__P ((wint_t __wc
, __locale_t __locale
));
275 /* Test for any wide character that corresponds to a locale-specific
276 set of wide characters for which none of `iswalnum', `iswgraph', or
277 `iswpunct' is true. */
278 extern int __iswspace_l
__P ((wint_t __wc
, __locale_t __locale
));
280 /* Test for any wide character that corresponds to an uppercase letter
281 or is one of a locale-specific set of wide character for which none
282 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
283 extern int __iswupper_l
__P ((wint_t __wc
, __locale_t __locale
));
285 /* Test for any wide character that corresponds to a hexadecimal-digit
286 character equivalent to that performed be the functions described
287 in the previous subclause. */
288 extern int __iswxdigit_l
__P ((wint_t __wc
, __locale_t __locale
));
290 /* Test for any wide character that corresponds to a standard blank
291 wide character or a locale-specific set of wide characters for
292 which `iswalnum' is false. */
293 extern int __iswblank_l
__P ((wint_t __wc
, __locale_t __locale
));
295 /* Construct value that describes a class of wide characters identified
296 by the string argument PROPERTY. */
297 extern wctype_t __wctype_l
__P ((__const
char *__property
,
298 __locale_t __locale
));
300 /* Determine whether the wide-character WC has the property described by
302 extern int __iswctype_l
__P ((wint_t __wc
, wctype_t __desc
,
303 __locale_t __locale
));
307 * Wide-character case-mapping functions.
310 /* Converts an uppercase letter to the corresponding lowercase letter. */
311 extern wint_t __towlower_l
__P ((wint_t __wc
, __locale_t __locale
));
313 /* Converts an lowercase letter to the corresponding uppercase letter. */
314 extern wint_t __towupper_l
__P ((wint_t __wc
, __locale_t __locale
));
316 /* Map the wide character WC using the mapping described by DESC. */
317 extern wint_t __towctrans_l
__P ((wint_t __wc
, wctrans_t __desc
,
318 __locale_t __locale
));
322 # define __iswalnum_l(wc, loc) __iswctype_l ((wc), _ISwalnum, (loc))
323 # define __iswalpha_l(wc, loc) __iswctype_l ((wc), _ISwalpha, (loc))
324 # define __iswcntrl_l(wc, loc) __iswctype_l ((wc), _ISwcntrl, (loc))
325 # define __iswdigit_l(wc, loc) __iswctype_l ((wc), _ISwdigit, (loc))
326 # define __iswlower_l(wc, loc) __iswctype_l ((wc), _ISwlower, (loc))
327 # define __iswgraph_l(wc, loc) __iswctype_l ((wc), _ISwgraph, (loc))
328 # define __iswprint_l(wc, loc) __iswctype_l ((wc), _ISwprint, (loc))
329 # define __iswpunct_l(wc, loc) __iswctype_l ((wc), _ISwpunct, (loc))
330 # define __iswspace_l(wc, loc) __iswctype_l ((wc), _ISwspace, (loc))
331 # define __iswupper_l(wc, loc) __iswctype_l ((wc), _ISwupper, (loc))
332 # define __iswxdigit_l(wc, loc) __iswctype_l ((wc), _ISwxdigit, (loc))
334 # define __iswblank_l(wc, loc) __iswctype_l ((wc), _ISwblank, (loc))
336 # define __towlower_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_tolower, \
338 # define __towupper_l(wc, loc) __towctrans_l ((wc), (loc)->__ctype_toupper, \
341 # endif /* Not __NO_WCTYPE. */
343 # endif /* Use GNU. */
347 #endif /* __WCTYPE_H defined. */
349 #endif /* wctype.h */