1/* Copyright (C) 1996-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
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.
8
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.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.25
20 * Wide character classification and mapping utilities <wctype.h>
21 */
22
23#ifndef _WCTYPE_H
24
25#include <features.h>
26#include <bits/types.h>
27
28#ifndef __need_iswxxx
29# define _WCTYPE_H 1
30
31/* Get wint_t from <wchar.h>. */
32# define __need_wint_t
33# include <wchar.h>
34
35/* Constant expression of type `wint_t' whose value does not correspond
36 to any member of the extended character set. */
37# ifndef WEOF
38# define WEOF (0xffffffffu)
39# endif
40#endif
41#undef __need_iswxxx
42
43
44/* The following part is also used in the <wcsmbs.h> header when compiled
45 in the Unix98 compatibility mode. */
46#ifndef __iswxxx_defined
47# define __iswxxx_defined 1
48
49__BEGIN_NAMESPACE_C99
50/* Scalar type that can hold values which represent locale-specific
51 character classifications. */
52typedef unsigned long int wctype_t;
53__END_NAMESPACE_C99
54
55# ifndef _ISwbit
56/* The characteristics are stored always in network byte order (big
57 endian). We define the bit value interpretations here dependent on the
58 machine's byte order. */
59
60# include <endian.h>
61# if __BYTE_ORDER == __BIG_ENDIAN
62# define _ISwbit(bit) (1 << (bit))
63# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
64# define _ISwbit(bit) \
65 ((bit) < 8 ? (int) ((1UL << (bit)) << 24) \
66 : ((bit) < 16 ? (int) ((1UL << (bit)) << 8) \
67 : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8) \
68 : (int) ((1UL << (bit)) >> 24))))
69# endif
70
71enum
72{
73 __ISwupper = 0, /* UPPERCASE. */
74 __ISwlower = 1, /* lowercase. */
75 __ISwalpha = 2, /* Alphabetic. */
76 __ISwdigit = 3, /* Numeric. */
77 __ISwxdigit = 4, /* Hexadecimal numeric. */
78 __ISwspace = 5, /* Whitespace. */
79 __ISwprint = 6, /* Printing. */
80 __ISwgraph = 7, /* Graphical. */
81 __ISwblank = 8, /* Blank (usually SPC and TAB). */
82 __ISwcntrl = 9, /* Control character. */
83 __ISwpunct = 10, /* Punctuation. */
84 __ISwalnum = 11, /* Alphanumeric. */
85
86 _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */
87 _ISwlower = _ISwbit (__ISwlower), /* lowercase. */
88 _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */
89 _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */
90 _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */
91 _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */
92 _ISwprint = _ISwbit (__ISwprint), /* Printing. */
93 _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */
94 _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */
95 _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */
96 _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */
97 _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */
98};
99# endif /* Not _ISwbit */
100
101
102__BEGIN_DECLS
103
104__BEGIN_NAMESPACE_C99
105/*
106 * Wide-character classification functions: 7.15.2.1.
107 */
108
109/* Test for any wide character for which `iswalpha' or `iswdigit' is
110 true. */
111extern int iswalnum (wint_t __wc) __THROW;
112
113/* Test for any wide character for which `iswupper' or 'iswlower' is
114 true, or any wide character that is one of a locale-specific set of
115 wide-characters for which none of `iswcntrl', `iswdigit',
116 `iswpunct', or `iswspace' is true. */
117extern int iswalpha (wint_t __wc) __THROW;
118
119/* Test for any control wide character. */
120extern int iswcntrl (wint_t __wc) __THROW;
121
122/* Test for any wide character that corresponds to a decimal-digit
123 character. */
124extern int iswdigit (wint_t __wc) __THROW;
125
126/* Test for any wide character for which `iswprint' is true and
127 `iswspace' is false. */
128extern int iswgraph (wint_t __wc) __THROW;
129
130/* Test for any wide character that corresponds to a lowercase letter
131 or is one of a locale-specific set of wide characters for which
132 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
133extern int iswlower (wint_t __wc) __THROW;
134
135/* Test for any printing wide character. */
136extern int iswprint (wint_t __wc) __THROW;
137
138/* Test for any printing wide character that is one of a
139 locale-specific et of wide characters for which neither `iswspace'
140 nor `iswalnum' is true. */
141extern int iswpunct (wint_t __wc) __THROW;
142
143/* Test for any wide character that corresponds to a locale-specific
144 set of wide characters for which none of `iswalnum', `iswgraph', or
145 `iswpunct' is true. */
146extern int iswspace (wint_t __wc) __THROW;
147
148/* Test for any wide character that corresponds to an uppercase letter
149 or is one of a locale-specific set of wide character for which none
150 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
151extern int iswupper (wint_t __wc) __THROW;
152
153/* Test for any wide character that corresponds to a hexadecimal-digit
154 character equivalent to that performed be the functions described
155 in the previous subclause. */
156extern int iswxdigit (wint_t __wc) __THROW;
157
158/* Test for any wide character that corresponds to a standard blank
159 wide character or a locale-specific set of wide characters for
160 which `iswalnum' is false. */
161# ifdef __USE_ISOC99
162extern int iswblank (wint_t __wc) __THROW;
163# endif
164
165/*
166 * Extensible wide-character classification functions: 7.15.2.2.
167 */
168
169/* Construct value that describes a class of wide characters identified
170 by the string argument PROPERTY. */
171extern wctype_t wctype (const char *__property) __THROW;
172
173/* Determine whether the wide-character WC has the property described by
174 DESC. */
175extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
176__END_NAMESPACE_C99
177
178
179/*
180 * Wide-character case-mapping functions: 7.15.3.1.
181 */
182
183__BEGIN_NAMESPACE_C99
184/* Scalar type that can hold values which represent locale-specific
185 character mappings. */
186typedef const __int32_t *wctrans_t;
187__END_NAMESPACE_C99
188#ifdef __USE_GNU
189__USING_NAMESPACE_C99(wctrans_t)
190#endif
191
192__BEGIN_NAMESPACE_C99
193/* Converts an uppercase letter to the corresponding lowercase letter. */
194extern wint_t towlower (wint_t __wc) __THROW;
195
196/* Converts an lowercase letter to the corresponding uppercase letter. */
197extern wint_t towupper (wint_t __wc) __THROW;
198__END_NAMESPACE_C99
199
200__END_DECLS
201
202#endif /* need iswxxx. */
203
204
205/* The remaining definitions and declarations must not appear in the
206 <wchar.h> header. */
207#ifdef _WCTYPE_H
208
209/*
210 * Extensible wide-character mapping functions: 7.15.3.2.
211 */
212
213__BEGIN_DECLS
214
215__BEGIN_NAMESPACE_C99
216/* Construct value that describes a mapping between wide characters
217 identified by the string argument PROPERTY. */
218extern wctrans_t wctrans (const char *__property) __THROW;
219
220/* Map the wide character WC using the mapping described by DESC. */
221extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
222__END_NAMESPACE_C99
223
224# ifdef __USE_XOPEN2K8
225/* Declare the interface to extended locale model. */
226# include <xlocale.h>
227
228/* Test for any wide character for which `iswalpha' or `iswdigit' is
229 true. */
230extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW;
231
232/* Test for any wide character for which `iswupper' or 'iswlower' is
233 true, or any wide character that is one of a locale-specific set of
234 wide-characters for which none of `iswcntrl', `iswdigit',
235 `iswpunct', or `iswspace' is true. */
236extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW;
237
238/* Test for any control wide character. */
239extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW;
240
241/* Test for any wide character that corresponds to a decimal-digit
242 character. */
243extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW;
244
245/* Test for any wide character for which `iswprint' is true and
246 `iswspace' is false. */
247extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW;
248
249/* Test for any wide character that corresponds to a lowercase letter
250 or is one of a locale-specific set of wide characters for which
251 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
252extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW;
253
254/* Test for any printing wide character. */
255extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW;
256
257/* Test for any printing wide character that is one of a
258 locale-specific et of wide characters for which neither `iswspace'
259 nor `iswalnum' is true. */
260extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
261
262/* Test for any wide character that corresponds to a locale-specific
263 set of wide characters for which none of `iswalnum', `iswgraph', or
264 `iswpunct' is true. */
265extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
266
267/* Test for any wide character that corresponds to an uppercase letter
268 or is one of a locale-specific set of wide character for which none
269 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
270extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW;
271
272/* Test for any wide character that corresponds to a hexadecimal-digit
273 character equivalent to that performed be the functions described
274 in the previous subclause. */
275extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW;
276
277/* Test for any wide character that corresponds to a standard blank
278 wide character or a locale-specific set of wide characters for
279 which `iswalnum' is false. */
280extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
281
282/* Construct value that describes a class of wide characters identified
283 by the string argument PROPERTY. */
284extern wctype_t wctype_l (const char *__property, __locale_t __locale)
285 __THROW;
286
287/* Determine whether the wide-character WC has the property described by
288 DESC. */
289extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
290 __THROW;
291
292
293/*
294 * Wide-character case-mapping functions.
295 */
296
297/* Converts an uppercase letter to the corresponding lowercase letter. */
298extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW;
299
300/* Converts an lowercase letter to the corresponding uppercase letter. */
301extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW;
302
303/* Construct value that describes a mapping between wide characters
304 identified by the string argument PROPERTY. */
305extern wctrans_t wctrans_l (const char *__property, __locale_t __locale)
306 __THROW;
307
308/* Map the wide character WC using the mapping described by DESC. */
309extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
310 __locale_t __locale) __THROW;
311
312# endif /* Use POSIX 2008. */
313
314__END_DECLS
315
316#endif /* __WCTYPE_H defined. */
317
318#endif /* wctype.h */
319