1/* Copyright (C) 1996,97,98,99,2000,01,02 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, write to the Free 16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 02111-1307 USA. */ 18 19/* 20 * ISO C99 Standard: 7.25 21 * Wide character classification and mapping utilities <wctype.h> 22 */ 23 24#ifndef _WCTYPE_H 25 26#include <features.h> 27#include <bits/types.h> 28 29#ifndef __need_iswxxx 30# define _WCTYPE_H 1 31 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 42typedef unsigned int wint_t; 43# else 44# ifdef __USE_ISOC99 45__USING_NAMESPACE_C99(wint_t) 46# endif 47__END_NAMESPACE_C99 48# endif 49 50/* Constant expression of type `wint_t' whose value does not correspond 51 to any member of the extended character set. */ 52# ifndef WEOF 53# define WEOF (0xffffffffu) 54# endif 55#endif 56#undef __need_iswxxx 57 58 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 63 64__BEGIN_NAMESPACE_C99 65/* Scalar type that can hold values which represent locale-specific 66 character classifications. */ 67typedef unsigned long int wctype_t; 68__END_NAMESPACE_C99 69 70# ifndef _ISwbit 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. */ 74 75# include <endian.h> 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)))) 84# endif 85 86enum 87{ 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. */ 100 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. */ 113}; 114# endif /* Not _ISwbit */ 115 116 117__BEGIN_DECLS 118 119__BEGIN_NAMESPACE_C99 120/* 121 * Wide-character classification functions: 7.15.2.1. 122 */ 123 124/* Test for any wide character for which `iswalpha' or `iswdigit' is 125 true. */ 126extern int iswalnum (wint_t __wc) __THROW; 127 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. */ 132extern int iswalpha (wint_t __wc) __THROW; 133 134/* Test for any control wide character. */ 135extern int iswcntrl (wint_t __wc) __THROW; 136 137/* Test for any wide character that corresponds to a decimal-digit 138 character. */ 139extern int iswdigit (wint_t __wc) __THROW; 140 141/* Test for any wide character for which `iswprint' is true and 142 `iswspace' is false. */ 143extern int iswgraph (wint_t __wc) __THROW; 144 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. */ 148extern int iswlower (wint_t __wc) __THROW; 149 150/* Test for any printing wide character. */ 151extern int iswprint (wint_t __wc) __THROW; 152 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. */ 156extern int iswpunct (wint_t __wc) __THROW; 157 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. */ 161extern int iswspace (wint_t __wc) __THROW; 162 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. */ 166extern int iswupper (wint_t __wc) __THROW; 167 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. */ 171extern int iswxdigit (wint_t __wc) __THROW; 172 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. */ 176# ifdef __USE_ISOC99 177extern int iswblank (wint_t __wc) __THROW; 178# endif 179 180/* 181 * Extensible wide-character classification functions: 7.15.2.2. 182 */ 183 184/* Construct value that describes a class of wide characters identified 185 by the string argument PROPERTY. */ 186extern wctype_t wctype (__const char *__property) __THROW; 187 188/* Determine whether the wide-character WC has the property described by 189 DESC. */ 190extern int iswctype (wint_t __wc, wctype_t __desc) __THROW; 191__END_NAMESPACE_C99 192 193 194/* 195 * Wide-character case-mapping functions: 7.15.3.1. 196 */ 197 198__BEGIN_NAMESPACE_C99 199/* Scalar type that can hold values which represent locale-specific 200 character mappings. */ 201typedef __const __int32_t *wctrans_t; 202__END_NAMESPACE_C99 203#ifdef __USE_GNU 204__USING_NAMESPACE_C99(wctrans_t) 205#endif 206 207__BEGIN_NAMESPACE_C99 208/* Converts an uppercase letter to the corresponding lowercase letter. */ 209extern wint_t towlower (wint_t __wc) __THROW; 210 211/* Converts an lowercase letter to the corresponding uppercase letter. */ 212extern wint_t towupper (wint_t __wc) __THROW; 213__END_NAMESPACE_C99 214 215__END_DECLS 216 217#endif /* need iswxxx. */ 218 219 220/* The remaining definitions and declarations must not appear in the 221 <wcsmbs.h> header. */ 222#ifdef _WCTYPE_H 223 224/* 225 * Extensible wide-character mapping functions: 7.15.3.2. 226 */ 227 228__BEGIN_DECLS 229 230__BEGIN_NAMESPACE_C99 231/* Construct value that describes a mapping between wide characters 232 identified by the string argument PROPERTY. */ 233extern wctrans_t wctrans (__const char *__property) __THROW; 234 235/* Map the wide character WC using the mapping described by DESC. */ 236extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW; 237__END_NAMESPACE_C99 238 239# ifdef __USE_GNU 240/* Declare the interface to extended locale model. */ 241# include <xlocale.h> 242 243/* Test for any wide character for which `iswalpha' or `iswdigit' is 244 true. */ 245extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW; 246 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. */ 251extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW; 252 253/* Test for any control wide character. */ 254extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW; 255 256/* Test for any wide character that corresponds to a decimal-digit 257 character. */ 258extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW; 259 260/* Test for any wide character for which `iswprint' is true and 261 `iswspace' is false. */ 262extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW; 263 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. */ 267extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW; 268 269/* Test for any printing wide character. */ 270extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW; 271 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. */ 275extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW; 276 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. */ 280extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW; 281 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. */ 285extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW; 286 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. */ 290extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW; 291 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. */ 295extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW; 296 297/* Construct value that describes a class of wide characters identified 298 by the string argument PROPERTY. */ 299extern wctype_t wctype_l (__const char *__property, __locale_t __locale) 300 __THROW; 301 302/* Determine whether the wide-character WC has the property described by 303 DESC. */ 304extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale) 305 __THROW; 306 307 308/* 309 * Wide-character case-mapping functions. 310 */ 311 312/* Converts an uppercase letter to the corresponding lowercase letter. */ 313extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW; 314 315/* Converts an lowercase letter to the corresponding uppercase letter. */ 316extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW; 317 318/* Construct value that describes a mapping between wide characters 319 identified by the string argument PROPERTY. */ 320extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale) 321 __THROW; 322 323/* Map the wide character WC using the mapping described by DESC. */ 324extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc, 325 __locale_t __locale) __THROW; 326 327# endif /* Use GNU. */ 328 329__END_DECLS 330 331#endif /* __WCTYPE_H defined. */ 332 333#endif /* wctype.h */ 334