Back to index

glibc  2.9
wctype.h
Go to the documentation of this file.
00001 /* Copyright (C) 1996-2002, 2005, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 /*
00020  *     ISO C99 Standard: 7.25
00021  *     Wide character classification and mapping utilities  <wctype.h>
00022  */
00023 
00024 #ifndef _WCTYPE_H
00025 
00026 #include <features.h>
00027 #include <bits/types.h>
00028 
00029 #ifndef __need_iswxxx
00030 # define _WCTYPE_H   1
00031 
00032 /* Get wint_t from <wchar.h>.  */
00033 # define __need_wint_t
00034 # include <wchar.h>
00035 
00036 /* Constant expression of type `wint_t' whose value does not correspond
00037    to any member of the extended character set.  */
00038 # ifndef WEOF
00039 #  define WEOF (0xffffffffu)
00040 # endif
00041 #endif
00042 #undef __need_iswxxx
00043 
00044 
00045 /* The following part is also used in the <wcsmbs.h> header when compiled
00046    in the Unix98 compatibility mode.  */
00047 #ifndef __iswxxx_defined
00048 # define __iswxxx_defined   1
00049 
00050 __BEGIN_NAMESPACE_C99
00051 /* Scalar type that can hold values which represent locale-specific
00052    character classifications.  */
00053 typedef unsigned long int wctype_t;
00054 __END_NAMESPACE_C99
00055 
00056 # ifndef _ISwbit
00057 /* The characteristics are stored always in network byte order (big
00058    endian).  We define the bit value interpretations here dependent on the
00059    machine's byte order.  */
00060 
00061 #  include <endian.h>
00062 #  if __BYTE_ORDER == __BIG_ENDIAN
00063 #   define _ISwbit(bit)     (1 << (bit))
00064 #  else /* __BYTE_ORDER == __LITTLE_ENDIAN */
00065 #   define _ISwbit(bit)     \
00066        ((bit) < 8 ? (int) ((1UL << (bit)) << 24)                     \
00067         : ((bit) < 16 ? (int) ((1UL << (bit)) << 8)                         \
00068            : ((bit) < 24 ? (int) ((1UL << (bit)) >> 8)                      \
00069               : (int) ((1UL << (bit)) >> 24))))
00070 #  endif
00071 
00072 enum
00073 {
00074   __ISwupper = 0,                  /* UPPERCASE.  */
00075   __ISwlower = 1,                  /* lowercase.  */
00076   __ISwalpha = 2,                  /* Alphabetic.  */
00077   __ISwdigit = 3,                  /* Numeric.  */
00078   __ISwxdigit = 4,                 /* Hexadecimal numeric.  */
00079   __ISwspace = 5,                  /* Whitespace.  */
00080   __ISwprint = 6,                  /* Printing.  */
00081   __ISwgraph = 7,                  /* Graphical.  */
00082   __ISwblank = 8,                  /* Blank (usually SPC and TAB).  */
00083   __ISwcntrl = 9,                  /* Control character.  */
00084   __ISwpunct = 10,                 /* Punctuation.  */
00085   __ISwalnum = 11,                 /* Alphanumeric.  */
00086 
00087   _ISwupper = _ISwbit (__ISwupper),       /* UPPERCASE.  */
00088   _ISwlower = _ISwbit (__ISwlower),       /* lowercase.  */
00089   _ISwalpha = _ISwbit (__ISwalpha),       /* Alphabetic.  */
00090   _ISwdigit = _ISwbit (__ISwdigit),       /* Numeric.  */
00091   _ISwxdigit = _ISwbit (__ISwxdigit),     /* Hexadecimal numeric.  */
00092   _ISwspace = _ISwbit (__ISwspace),       /* Whitespace.  */
00093   _ISwprint = _ISwbit (__ISwprint),       /* Printing.  */
00094   _ISwgraph = _ISwbit (__ISwgraph),       /* Graphical.  */
00095   _ISwblank = _ISwbit (__ISwblank),       /* Blank (usually SPC and TAB).  */
00096   _ISwcntrl = _ISwbit (__ISwcntrl),       /* Control character.  */
00097   _ISwpunct = _ISwbit (__ISwpunct),       /* Punctuation.  */
00098   _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric.  */
00099 };
00100 # endif /* Not _ISwbit  */
00101 
00102 
00103 __BEGIN_DECLS
00104 
00105 __BEGIN_NAMESPACE_C99
00106 /*
00107  * Wide-character classification functions: 7.15.2.1.
00108  */
00109 
00110 /* Test for any wide character for which `iswalpha' or `iswdigit' is
00111    true.  */
00112 extern int iswalnum (wint_t __wc) __THROW;
00113 
00114 /* Test for any wide character for which `iswupper' or 'iswlower' is
00115    true, or any wide character that is one of a locale-specific set of
00116    wide-characters for which none of `iswcntrl', `iswdigit',
00117    `iswpunct', or `iswspace' is true.  */
00118 extern int iswalpha (wint_t __wc) __THROW;
00119 
00120 /* Test for any control wide character.  */
00121 extern int iswcntrl (wint_t __wc) __THROW;
00122 
00123 /* Test for any wide character that corresponds to a decimal-digit
00124    character.  */
00125 extern int iswdigit (wint_t __wc) __THROW;
00126 
00127 /* Test for any wide character for which `iswprint' is true and
00128    `iswspace' is false.  */
00129 extern int iswgraph (wint_t __wc) __THROW;
00130 
00131 /* Test for any wide character that corresponds to a lowercase letter
00132    or is one of a locale-specific set of wide characters for which
00133    none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
00134 extern int iswlower (wint_t __wc) __THROW;
00135 
00136 /* Test for any printing wide character.  */
00137 extern int iswprint (wint_t __wc) __THROW;
00138 
00139 /* Test for any printing wide character that is one of a
00140    locale-specific et of wide characters for which neither `iswspace'
00141    nor `iswalnum' is true.  */
00142 extern int iswpunct (wint_t __wc) __THROW;
00143 
00144 /* Test for any wide character that corresponds to a locale-specific
00145    set of wide characters for which none of `iswalnum', `iswgraph', or
00146    `iswpunct' is true.  */
00147 extern int iswspace (wint_t __wc) __THROW;
00148 
00149 /* Test for any wide character that corresponds to an uppercase letter
00150    or is one of a locale-specific set of wide character for which none
00151    of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
00152 extern int iswupper (wint_t __wc) __THROW;
00153 
00154 /* Test for any wide character that corresponds to a hexadecimal-digit
00155    character equivalent to that performed be the functions described
00156    in the previous subclause.  */
00157 extern int iswxdigit (wint_t __wc) __THROW;
00158 
00159 /* Test for any wide character that corresponds to a standard blank
00160    wide character or a locale-specific set of wide characters for
00161    which `iswalnum' is false.  */
00162 # ifdef __USE_ISOC99
00163 extern int iswblank (wint_t __wc) __THROW;
00164 # endif
00165 
00166 /*
00167  * Extensible wide-character classification functions: 7.15.2.2.
00168  */
00169 
00170 /* Construct value that describes a class of wide characters identified
00171    by the string argument PROPERTY.  */
00172 extern wctype_t wctype (__const char *__property) __THROW;
00173 
00174 /* Determine whether the wide-character WC has the property described by
00175    DESC.  */
00176 extern int iswctype (wint_t __wc, wctype_t __desc) __THROW;
00177 __END_NAMESPACE_C99
00178 
00179 
00180 /*
00181  * Wide-character case-mapping functions: 7.15.3.1.
00182  */
00183 
00184 __BEGIN_NAMESPACE_C99
00185 /* Scalar type that can hold values which represent locale-specific
00186    character mappings.  */
00187 typedef __const __int32_t *wctrans_t;
00188 __END_NAMESPACE_C99
00189 #ifdef __USE_GNU
00190 __USING_NAMESPACE_C99(wctrans_t)
00191 #endif
00192 
00193 __BEGIN_NAMESPACE_C99
00194 /* Converts an uppercase letter to the corresponding lowercase letter.  */
00195 extern wint_t towlower (wint_t __wc) __THROW;
00196 
00197 /* Converts an lowercase letter to the corresponding uppercase letter.  */
00198 extern wint_t towupper (wint_t __wc) __THROW;
00199 __END_NAMESPACE_C99
00200 
00201 __END_DECLS
00202 
00203 #endif /* need iswxxx.  */
00204 
00205 
00206 /* The remaining definitions and declarations must not appear in the
00207    <wcsmbs.h> header.  */
00208 #ifdef _WCTYPE_H
00209 
00210 /*
00211  * Extensible wide-character mapping functions: 7.15.3.2.
00212  */
00213 
00214 __BEGIN_DECLS
00215 
00216 __BEGIN_NAMESPACE_C99
00217 /* Construct value that describes a mapping between wide characters
00218    identified by the string argument PROPERTY.  */
00219 extern wctrans_t wctrans (__const char *__property) __THROW;
00220 
00221 /* Map the wide character WC using the mapping described by DESC.  */
00222 extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW;
00223 __END_NAMESPACE_C99
00224 
00225 # ifdef __USE_GNU
00226 /* Declare the interface to extended locale model.  */
00227 #  include <xlocale.h>
00228 
00229 /* Test for any wide character for which `iswalpha' or `iswdigit' is
00230    true.  */
00231 extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW;
00232 
00233 /* Test for any wide character for which `iswupper' or 'iswlower' is
00234    true, or any wide character that is one of a locale-specific set of
00235    wide-characters for which none of `iswcntrl', `iswdigit',
00236    `iswpunct', or `iswspace' is true.  */
00237 extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW;
00238 
00239 /* Test for any control wide character.  */
00240 extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW;
00241 
00242 /* Test for any wide character that corresponds to a decimal-digit
00243    character.  */
00244 extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW;
00245 
00246 /* Test for any wide character for which `iswprint' is true and
00247    `iswspace' is false.  */
00248 extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW;
00249 
00250 /* Test for any wide character that corresponds to a lowercase letter
00251    or is one of a locale-specific set of wide characters for which
00252    none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
00253 extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW;
00254 
00255 /* Test for any printing wide character.  */
00256 extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW;
00257 
00258 /* Test for any printing wide character that is one of a
00259    locale-specific et of wide characters for which neither `iswspace'
00260    nor `iswalnum' is true.  */
00261 extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW;
00262 
00263 /* Test for any wide character that corresponds to a locale-specific
00264    set of wide characters for which none of `iswalnum', `iswgraph', or
00265    `iswpunct' is true.  */
00266 extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW;
00267 
00268 /* Test for any wide character that corresponds to an uppercase letter
00269    or is one of a locale-specific set of wide character for which none
00270    of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true.  */
00271 extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW;
00272 
00273 /* Test for any wide character that corresponds to a hexadecimal-digit
00274    character equivalent to that performed be the functions described
00275    in the previous subclause.  */
00276 extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW;
00277 
00278 /* Test for any wide character that corresponds to a standard blank
00279    wide character or a locale-specific set of wide characters for
00280    which `iswalnum' is false.  */
00281 extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW;
00282 
00283 /* Construct value that describes a class of wide characters identified
00284    by the string argument PROPERTY.  */
00285 extern wctype_t wctype_l (__const char *__property, __locale_t __locale)
00286      __THROW;
00287 
00288 /* Determine whether the wide-character WC has the property described by
00289    DESC.  */
00290 extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
00291      __THROW;
00292 
00293 
00294 /*
00295  * Wide-character case-mapping functions.
00296  */
00297 
00298 /* Converts an uppercase letter to the corresponding lowercase letter.  */
00299 extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW;
00300 
00301 /* Converts an lowercase letter to the corresponding uppercase letter.  */
00302 extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW;
00303 
00304 /* Construct value that describes a mapping between wide characters
00305    identified by the string argument PROPERTY.  */
00306 extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale)
00307      __THROW;
00308 
00309 /* Map the wide character WC using the mapping described by DESC.  */
00310 extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc,
00311                         __locale_t __locale) __THROW;
00312 
00313 # endif /* Use GNU.  */
00314 
00315 __END_DECLS
00316 
00317 #endif /* __WCTYPE_H defined.  */
00318 
00319 #endif /* wctype.h  */