1 /* Copyright (C) 1996 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
16 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO/IEC 9899:1990/Amendment 1:1995 7.15:
21 * Wide-character classification and mapping utilities <wctype.h>
32 /* FIXME: should this go into <stddef.h>??? */
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 typedef unsigned int wint_t;
44 /* Scalar type that can hold values which represent locale-specific
45 character mappings. */
46 typedef const unsigned int *wctrans_t;
48 /* Scalar type that can hold values which represent locale-specific
49 character classifications. */
51 typedef unsigned long int wctype_t;
53 /* For compatibility reasons we have to use shorts for now. */
54 typedef unsigned short int wctype_t;
58 /* Constant expression of type `wint_t' whose value does not correspond
59 to any member of the extended character set. */
61 #define WEOF (0xffffffffu)
65 /* These are all the characteristics of characters.
66 If there get to be more than 16 distinct characteristics,
67 many things must be changed that use `unsigned short int's.
69 The characteristics are stored always in network byte order (big
70 endian). We define the bit value interpretations here dependent on the
71 machine's byte order. */
74 #if __BYTE_ORDER == __BIG_ENDIAN
75 #define _ISbit(bit) (1 << bit)
76 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */
77 #define _ISbit(bit) (bit < 8 ? ((1 << bit) << 8) : ((1 << bit) >> 8))
82 _ISupper = _ISbit (0), /* UPPERCASE. */
83 _ISlower = _ISbit (1), /* lowercase. */
84 _ISalpha = _ISbit (2), /* Alphabetic. */
85 _ISdigit = _ISbit (3), /* Numeric. */
86 _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */
87 _ISspace = _ISbit (5), /* Whitespace. */
88 _ISprint = _ISbit (6), /* Printing. */
89 _ISgraph = _ISbit (7), /* Graphical. */
90 _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */
91 _IScntrl = _ISbit (9), /* Control character. */
92 _ISpunct = _ISbit (10), /* Punctuation. */
93 _ISalnum = _ISbit (11) /* Alphanumeric. */
95 #endif /* Not _ISbit */
99 * Wide-character classification functions: 7.15.2.1.
102 /* Test for any wide character for which `iswalpha' or `iswdigit' is
104 int iswalnum __P ((wint_t __wc));
106 /* Test for any wide character for which `iswupper' or 'iswlower' is
107 true, or any wide character that is one of a locale-specific set of
108 wide-characters for which none of `iswcntrl', `iswdigit',
109 `iswpunct', or `iswspace' is true. */
110 int iswalpha __P ((wint_t __wc));
112 /* Test for any control wide character. */
113 int iswcntrl __P ((wint_t __wc));
115 /* Test for any wide character that corresponds to a decimal-digit
117 int iswdigit __P ((wint_t __wc));
119 /* Test for any wide character for which `iswprint' is true and
120 `iswspace' is false. */
121 int iswgraph __P ((wint_t __wc));
123 /* Test for any wide character that corresponds to a lowercase letter
124 or is one of a locale-specific set of wide characters for which
125 none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
126 int iswlower __P ((wint_t __wc));
128 /* Test for any printing wide character. */
129 int iswprint __P ((wint_t __wc));
131 /* Test for any printing wide character that is one of a
132 locale-specific et of wide characters for which neither `iswspace'
133 nor `iswalnum' is true. */
134 int iswpunct __P ((wint_t __wc));
136 /* Test for any wide character that corresponds to a locale-specific
137 set of wide characters for which none of `iswalnum', `iswgraph', or
138 `iswpunct' is true. */
139 int iswspace __P ((wint_t __wc));
141 /* Test for any wide character that corresponds to an uppercase letter
142 or is one of a locale-specific set of wide character for which none
143 of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */
144 int iswupper __P ((wint_t __wc));
146 /* Test for any wide character that corresponds to a hexadecimal-digit
147 character equivalent to that performed be the functions described
148 in the previous subclause. */
149 int iswxdigit __P ((wint_t __wc));
152 * Extensible wide-character classification functions: 7.15.2.2.
155 /* Construct value that describes a class of wide characters identified
156 by the string argument PROPERTY. */
157 wctype_t wctype __P ((__const char *__property));
159 /* Determine whether the wide-character WC has the property described by
161 int iswctype __P ((wint_t __wc, wctype_t __desc));
165 * Wide-character case-mapping functions: 7.15.3.1.
168 /* Converts an uppercase letter to the corresponding lowercase letter. */
169 wint_t towlower __P ((wint_t __wc));
171 /* Converts an lowercase letter to the corresponding uppercase letter. */
172 wint_t towupper __P ((wint_t __wc));
175 * Extensible wide-character mapping functions: 7.15.3.2.
178 /* Construct value that describes a mapping between wide characters
179 identified by the string argument PROPERTY. */
180 wctrans_t wctrans __P ((__const char *__property));
182 /* Map the wide character WC using the mapping described by DESC. */
183 wint_t towctrans __P ((wint_t __wc, wctrans_t __desc));
188 #define iswalnum(wc) iswctype ((wc), _ISalnum)
189 #define iswalpha(wc) iswctype ((wc), _ISalpha)
190 #define iswcntrl(wc) iswctype ((wc), _IScntrl)
191 #define iswdigit(wc) iswctype ((wc), _ISdigit)
192 #define iswlower(wc) iswctype ((wc), _ISlower)
193 #define iswgraph(wc) iswctype ((wc), _ISgraph)
194 #define iswprint(wc) iswctype ((wc), _ISprint)
195 #define iswpunct(wc) iswctype ((wc), _ISpunct)
196 #define iswspace(wc) iswctype ((wc), _ISspace)
197 #define iswupper(wc) iswctype ((wc), _ISupper)
198 #define iswxdigit(wc) iswctype ((wc), _ISxdigit)
201 #define iswblank(wc) iswctype ((wc), _ISblank)
204 /* Pointer to conversion tables. */
205 extern __const int *__ctype_tolower; /* Case conversions. */
206 extern __const int *__ctype_toupper; /* Case conversions. */
208 #define towlower(wc) towctrans (wc, __ctype_tolower)
209 #define towupper(wc) towctrans (wc, __ctype_toupper)
211 #endif /* Not __NO_WCTYPE. */
215 #endif /* wctype.h */