1 /* Copyright (C) 1996,97,98,99,2000,01,02 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
20 * ISO C99 Standard: 7.25
21 * Wide character classification and mapping utilities <wctype.h>
27 #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 __USING_NAMESPACE_C99(wint_t)
50 /* Constant expression of type `wint_t' whose value does not correspond
51 to any member of the extended character set. */
53 # define WEOF (0xffffffffu)
59 /* The following part is also used in the <wcsmbs.h> header when compiled
60 in the Unix98 compatibility mode. */
61 #ifndef __iswxxx_defined
62 # define __iswxxx_defined 1
65 /* Scalar type that can hold values which represent locale-specific
66 character classifications. */
67 typedef unsigned long int wctype_t;
71 /* The characteristics are stored always in network byte order (big
72 endian). We define the bit value interpretations here dependent on the
73 machine's byte order. */
76 # if __BYTE_ORDER == __BIG_ENDIAN
77 # define _ISwbit(bit) (1 << (bit))
78 # else /* __BYTE_ORDER == __LITTLE_ENDIAN */
79 # define _ISwbit(bit) \
80 ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \
81 : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \
82 : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \
83 : (int) ((1UL << (bit)) >> 24))))
88 __ISwupper
= 0, /* UPPERCASE. */
89 __ISwlower
= 1, /* lowercase. */
90 __ISwalpha
= 2, /* Alphabetic. */
91 __ISwdigit
= 3, /* Numeric. */
92 __ISwxdigit
= 4, /* Hexadecimal numeric. */
93 __ISwspace
= 5, /* Whitespace. */
94 __ISwprint
= 6, /* Printing. */
95 __ISwgraph
= 7, /* Graphical. */
96 __ISwblank
= 8, /* Blank (usually SPC and TAB). */
97 __ISwcntrl
= 9, /* Control character. */
98 __ISwpunct
= 10, /* Punctuation. */
99 __ISwalnum
= 11, /* Alphanumeric. */
101 _ISwupper
= _ISwbit (__ISwupper
), /* UPPERCASE. */
102 _ISwlower
= _ISwbit (__ISwlower
), /* lowercase. */
103 _ISwalpha
= _ISwbit (__ISwalpha
), /* Alphabetic. */
104 _ISwdigit
= _ISwbit (__ISwdigit
), /* Numeric. */
105 _ISwxdigit
= _ISwbit (__ISwxdigit
), /* Hexadecimal numeric. */
106 _ISwspace
= _ISwbit (__ISwspace
), /* Whitespace. */
107 _ISwprint
= _ISwbit (__ISwprint
), /* Printing. */
108 _ISwgraph
= _ISwbit (__ISwgraph
), /* Graphical. */
109 _ISwblank
= _ISwbit (__ISwblank
), /* Blank (usually SPC and TAB). */
110 _ISwcntrl
= _ISwbit (__ISwcntrl
), /* Control character. */
111 _ISwpunct
= _ISwbit (__ISwpunct
), /* Punctuation. */
112 _ISwalnum
= _ISwbit (__ISwalnum
) /* Alphanumeric. */
114 # endif /* Not _ISwbit */
119 __BEGIN_NAMESPACE_C99
121 * Wide-character classification functions: 7.15.2.1.
124 /* Test for any wide character for which `iswalpha' or `iswdigit' is
126 extern int iswalnum (wint_t __wc
) __THROW
;
128 /* Test for any wide character for which `iswupper' or 'iswlower' is
129 true, or any wide character that is one of a locale-specific set of
130 wide-characters for which none of `iswcntrl', `iswdigit',
131 `iswpunct', or `iswspace' is true. */
132 extern int iswalpha (wint_t __wc
) __THROW
;
134 /* Test for any control wide character. */
135 extern int iswcntrl (wint_t __wc
) __THROW
;
137 /* Test for any wide character that corresponds to a decimal-digit
139 extern int iswdigit (wint_t __wc
) __THROW
;
141 /* Test for any wide character for which `iswprint' is true and
142 `iswspace' is false. */
143 extern int iswgraph (wint_t __wc
) __THROW
;
145 /* Test for any wide character that corresponds to a lowercase letter
146 or is one of a locale-specific set of wide characters for which
147 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
148 extern int iswlower (wint_t __wc
) __THROW
;
150 /* Test for any printing wide character. */
151 extern int iswprint (wint_t __wc
) __THROW
;
153 /* Test for any printing wide character that is one of a
154 locale-specific et of wide characters for which neither `iswspace'
155 nor `iswalnum' is true. */
156 extern int iswpunct (wint_t __wc
) __THROW
;
158 /* Test for any wide character that corresponds to a locale-specific
159 set of wide characters for which none of `iswalnum', `iswgraph', or
160 `iswpunct' is true. */
161 extern int iswspace (wint_t __wc
) __THROW
;
163 /* Test for any wide character that corresponds to an uppercase letter
164 or is one of a locale-specific set of wide character for which none
165 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
166 extern int iswupper (wint_t __wc
) __THROW
;
168 /* Test for any wide character that corresponds to a hexadecimal-digit
169 character equivalent to that performed be the functions described
170 in the previous subclause. */
171 extern int iswxdigit (wint_t __wc
) __THROW
;
173 /* Test for any wide character that corresponds to a standard blank
174 wide character or a locale-specific set of wide characters for
175 which `iswalnum' is false. */
177 extern int iswblank (wint_t __wc
) __THROW
;
181 * Extensible wide-character classification functions: 7.15.2.2.
184 /* Construct value that describes a class of wide characters identified
185 by the string argument PROPERTY. */
186 extern wctype_t wctype (__const
char *__property
) __THROW
;
188 /* Determine whether the wide-character WC has the property described by
190 extern int iswctype (wint_t __wc
, wctype_t __desc
) __THROW
;
195 * Wide-character case-mapping functions: 7.15.3.1.
198 __BEGIN_NAMESPACE_C99
199 /* Scalar type that can hold values which represent locale-specific
200 character mappings. */
201 typedef __const __int32_t
*wctrans_t;
204 __USING_NAMESPACE_C99(wctrans_t)
207 __BEGIN_NAMESPACE_C99
208 /* Converts an uppercase letter to the corresponding lowercase letter. */
209 extern wint_t towlower (wint_t __wc
) __THROW
;
211 /* Converts an lowercase letter to the corresponding uppercase letter. */
212 extern wint_t towupper (wint_t __wc
) __THROW
;
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 __BEGIN_NAMESPACE_C99
231 /* Construct value that describes a mapping between wide characters
232 identified by the string argument PROPERTY. */
233 extern wctrans_t wctrans (__const
char *__property
) __THROW
;
235 /* Map the wide character WC using the mapping described by DESC. */
236 extern wint_t towctrans (wint_t __wc
, wctrans_t __desc
) __THROW
;
240 /* Declare the interface to extended locale model. */
241 # include <xlocale.h>
243 /* Test for any wide character for which `iswalpha' or `iswdigit' is
245 extern int iswalnum_l (wint_t __wc
, __locale_t __locale
) __THROW
;
247 /* Test for any wide character for which `iswupper' or 'iswlower' is
248 true, or any wide character that is one of a locale-specific set of
249 wide-characters for which none of `iswcntrl', `iswdigit',
250 `iswpunct', or `iswspace' is true. */
251 extern int iswalpha_l (wint_t __wc
, __locale_t __locale
) __THROW
;
253 /* Test for any control wide character. */
254 extern int iswcntrl_l (wint_t __wc
, __locale_t __locale
) __THROW
;
256 /* Test for any wide character that corresponds to a decimal-digit
258 extern int iswdigit_l (wint_t __wc
, __locale_t __locale
) __THROW
;
260 /* Test for any wide character for which `iswprint' is true and
261 `iswspace' is false. */
262 extern int iswgraph_l (wint_t __wc
, __locale_t __locale
) __THROW
;
264 /* Test for any wide character that corresponds to a lowercase letter
265 or is one of a locale-specific set of wide characters for which
266 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
267 extern int iswlower_l (wint_t __wc
, __locale_t __locale
) __THROW
;
269 /* Test for any printing wide character. */
270 extern int iswprint_l (wint_t __wc
, __locale_t __locale
) __THROW
;
272 /* Test for any printing wide character that is one of a
273 locale-specific et of wide characters for which neither `iswspace'
274 nor `iswalnum' is true. */
275 extern int iswpunct_l (wint_t __wc
, __locale_t __locale
) __THROW
;
277 /* Test for any wide character that corresponds to a locale-specific
278 set of wide characters for which none of `iswalnum', `iswgraph', or
279 `iswpunct' is true. */
280 extern int iswspace_l (wint_t __wc
, __locale_t __locale
) __THROW
;
282 /* Test for any wide character that corresponds to an uppercase letter
283 or is one of a locale-specific set of wide character for which none
284 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
285 extern int iswupper_l (wint_t __wc
, __locale_t __locale
) __THROW
;
287 /* Test for any wide character that corresponds to a hexadecimal-digit
288 character equivalent to that performed be the functions described
289 in the previous subclause. */
290 extern int iswxdigit_l (wint_t __wc
, __locale_t __locale
) __THROW
;
292 /* Test for any wide character that corresponds to a standard blank
293 wide character or a locale-specific set of wide characters for
294 which `iswalnum' is false. */
295 extern int iswblank_l (wint_t __wc
, __locale_t __locale
) __THROW
;
297 /* Construct value that describes a class of wide characters identified
298 by the string argument PROPERTY. */
299 extern wctype_t wctype_l (__const
char *__property
, __locale_t __locale
)
302 /* Determine whether the wide-character WC has the property described by
304 extern int iswctype_l (wint_t __wc
, wctype_t __desc
, __locale_t __locale
)
309 * Wide-character case-mapping functions.
312 /* Converts an uppercase letter to the corresponding lowercase letter. */
313 extern wint_t towlower_l (wint_t __wc
, __locale_t __locale
) __THROW
;
315 /* Converts an lowercase letter to the corresponding uppercase letter. */
316 extern wint_t towupper_l (wint_t __wc
, __locale_t __locale
) __THROW
;
318 /* Construct value that describes a mapping between wide characters
319 identified by the string argument PROPERTY. */
320 extern wctrans_t wctrans_l (__const
char *__property
, __locale_t __locale
)
323 /* Map the wide character WC using the mapping described by DESC. */
324 extern wint_t towctrans_l (wint_t __wc
, wctrans_t __desc
,
325 __locale_t __locale
) __THROW
;
327 # endif /* Use GNU. */
331 #endif /* __WCTYPE_H defined. */
333 #endif /* wctype.h */