1 /** @file
2     Wide character classification and mapping utilities.
3 
4     The following macros are defined in this file:<BR>
5 @verbatim
6       WEOF        Wide char version of end-of-file.
7 @endverbatim
8 
9     The following types are defined in this file:<BR>
10 @verbatim
11       wint_t      Type capable of holding all wchar_t values and WEOF.
12       wctrans_t   A type for holding locale-specific character mappings.
13       wctype_t    Type for holding locale-specific character classifications.
14 @endverbatim
15 
16     The following functions are declared in this file:<BR>
17 @verbatim
18       ###############  Wide Character Classification Functions
19       int           iswalnum  (wint_t);
20       int           iswalpha  (wint_t);
21       int           iswcntrl  (wint_t);
22       int           iswdigit  (wint_t);
23       int           iswgraph  (wint_t);
24       int           iswlower  (wint_t);
25       int           iswprint  (wint_t);
26       int           iswpunct  (wint_t);
27       int           iswblank  (wint_t);
28       int           iswspace  (wint_t);
29       int           iswupper  (wint_t);
30       int           iswxdigit (wint_t);
31 
32       ###############  Extensible Wide Character Classification Functions
33       wctype_t      wctype    (const char *);
34       int           iswctype  (wint_t, wctype_t);
35 
36       ###############  Wide Character Case Mapping Utilities
37       wint_t        towlower  (wint_t);
38       wint_t        towupper  (wint_t);
39 
40       ###############  Extensible Wide Character Case Mapping Utilities
41       wctrans_t     wctrans   (const char *);
42       wint_t        towctrans (wint_t, wctrans_t);
43 @endverbatim
44 
45     Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
46     This program and the accompanying materials are licensed and made available under
47     the terms and conditions of the BSD License that accompanies this distribution.
48     The full text of the license may be found at
49     http://opensource.org/licenses/bsd-license.
50 
51     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
52     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
53 
54  * Copyright (c)1999 Citrus Project,
55  * All rights reserved.
56  *
57  * Redistribution and use in source and binary forms, with or without
58  * modification, are permitted provided that the following conditions
59  * are met:
60  * 1. Redistributions of source code must retain the above copyright
61  *    notice, this list of conditions and the following disclaimer.
62  * 2. Redistributions in binary form must reproduce the above copyright
63  *    notice, this list of conditions and the following disclaimer in the
64  *    documentation and/or other materials provided with the distribution.
65  *
66  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
67  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
68  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
69  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
70  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
71  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
72  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
73  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
74  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
75  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
76  * SUCH DAMAGE.
77  *
78  *  citrus Id: wctype.h,v 1.4 2000/12/21 01:50:21 itojun Exp
79 
80     NetBSD: wctype.h,v 1.6 2005/02/03 04:39:32 perry Exp
81 **/
82 #ifndef _WCTYPE_H_
83 #define _WCTYPE_H_
84 
85 #include  <sys/EfiCdefs.h>
86 #include  <machine/ansi.h>
87 
88 #ifdef _EFI_WINT_T
89   /** wint_t is an integer type unchanged by default argument promotions that can
90       hold any value corresponding to members of the extended character set, as
91       well as at least one value that does not correspond to any member of the
92       extended character set: WEOF.
93   */
94   typedef _EFI_WINT_T  wint_t;
95   #undef _BSD_WINT_T_
96   #undef _EFI_WINT_T
97 #endif
98 
99 #ifdef  _BSD_WCTRANS_T_
100   /** A scalar type for holding locale-specific character mappings. */
101   typedef wint_t (*wctrans_t)(wint_t);
102   #undef  _BSD_WCTRANS_T_
103 #endif
104 
105 #ifdef  _BSD_WCTYPE_T_
106   /** A scalar type capable of holding values representing locale-specific
107       character classifications. */
108   typedef _BSD_WCTYPE_T_  wctype_t;
109   #undef  _BSD_WCTYPE_T_
110 #endif
111 
112 #ifndef WEOF
113   /** WEOF expands to a constant expression of type wint_t whose value does not
114       correspond to any member of the extended character set. It is accepted
115       (and returned) by several functions, declared in this file, to indicate
116       end-of-file, that is, no more input from a stream. It is also used as a
117       wide character value that does not correspond to any member of the
118       extended character set.
119   */
120   #define WEOF  ((wint_t)-1)
121 #endif
122 
123 __BEGIN_DECLS
124   /** Test for any wide character for which iswalpha or iswdigit is TRUE.
125 
126     @param[in]  WC    The wide character to be classified.
127 
128     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
129               to the classification described for this function.
130   */
131   int           iswalnum  (wint_t WC);
132 
133   /** Test for any wide character for which iswupper or iswlower is TRUE,
134       OR, a locale-specific character where none of iswcntrl, iswdigit,
135       iswpunct, or iswspace is TRUE.
136 
137     @param[in]  WC    The wide character to be classified.
138 
139     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
140               to the classification described for this function.
141   */
142   int           iswalpha  (wint_t WC);
143 
144   /** Test for any wide control character.
145 
146     @param[in]  WC    The wide character to be classified.
147 
148     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
149               to the classification described for this function.
150   */
151   int           iswcntrl  (wint_t WC);
152 
153   /** Test if the value of WC is a wide character that corresponds to a decimal digit.
154 
155     @param[in]  WC    The wide character to be classified.
156 
157     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
158               to the classification described for this function.
159   */
160   int           iswdigit  (wint_t WC);
161 
162   /** Test for wide characters for which iswprint is TRUE and iswspace is FALSE.
163 
164     @param[in]  WC    The wide character to be classified.
165 
166     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
167               to the classification described for this function.
168   */
169   int           iswgraph  (wint_t WC);
170 
171   /** The iswlower function tests for any wide character that corresponds to a
172       lowercase letter or is one of a locale-specific set of wide characters
173       for which none of iswcntrl, iswdigit, iswpunct, or iswspace is TRUE.
174 
175     @param[in]  WC    The wide character to be classified.
176 
177     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
178               to the classification described for this function.
179   */
180   int           iswlower  (wint_t WC);
181 
182   /** Test for any printing wide character.
183 
184     @param[in]  WC    The wide character to be classified.
185 
186     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
187               to the classification described for this function.
188   */
189   int           iswprint  (wint_t WC);
190 
191   /** The iswpunct function tests for any printing wide character that is one
192       of a locale-specific set of punctuation wide characters for which
193       neither iswspace nor iswalnum is TRUE.
194 
195     @param[in]  WC    The wide character to be classified.
196 
197     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
198               to the classification described for this function.
199   */
200   int           iswpunct  (wint_t WC);
201 
202   /** Test for standard blank characters or locale-specific characters
203       for which iswspace is TRUE and are used to separate words within a line
204       of text.  In the "C" locale, iswblank only returns TRUE for the standard
205       blank characters space (L' ') and horizontal tab (L'\t').
206 
207     @param[in]  WC    The wide character to be classified.
208 
209     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
210               to the classification described for this function.
211   */
212   int           iswblank  (wint_t WC);
213 
214   /** The iswspace function tests for any wide character that corresponds to a
215       locale-specific set of white-space wide characters for which none of
216       iswalnum, iswgraph, or iswpunct is TRUE.
217 
218     @param[in]  WC    The wide character to be classified.
219 
220     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
221               to the classification described for this function.
222   */
223   int           iswspace  (wint_t WC);
224 
225   /** Tests for any wide character that corresponds to an uppercase letter or
226       is one of a locale-specific set of wide characters for which none of
227       iswcntrl, iswdigit, iswpunct, or iswspace is TRUE.
228 
229     @param[in]  WC    The wide character to be classified.
230 
231     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
232               to the classification described for this function.
233   */
234   int           iswupper  (wint_t WC);
235 
236   /** The iswxdigit function tests for any wide character that corresponds to a
237       hexadecimal-digit character.
238 
239     @param[in]  WC    The wide character to be classified.
240 
241     @return   Returns non-zero (TRUE) if and only if the value of WC conforms
242               to the classification described for this function.
243   */
244   int           iswxdigit (wint_t WC);
245 
246   /** Construct a value that describes a class of wide characters, identified
247       by the string pointed to by Desc.  The constructed value is suitable for
248       use as the second argument to the iswctype function.
249 
250       The following strings name classes of wide characters that the iswctype
251       function is able to test against.  These strings are valid in all locales
252       as Desc arguments to wctype().
253         - "alnum"
254         - "alpha"
255         - "blank"
256         - "cntrl"
257         - "digit"
258         - "graph"
259         - "lower"
260         - "print"
261         - "punct"
262         - "space"
263         - "upper"
264         - "xdigit
265 
266     @param[in]  Desc    A pointer to a multibyte character string naming a
267                         class of wide characters.
268 
269     @return   If Desc identifies a valid class of wide characters in the
270               current locale, the wctype function returns a nonzero value that
271               is valid as the second argument to the iswctype function;
272               otherwise, it returns zero.
273   */
274   wctype_t      wctype    (const char *Desc);
275 
276   /** Determine whether the wide character WC has the property described by Wct.
277 
278     @param[in]  WC      The wide character to be classified.
279     @param[in]  Wct     A value describing a class of wide characters.
280 
281     @return   The iswctype function returns nonzero (TRUE) if and only if the
282               value of the wide character WC has the property described by Wct.
283   */
284   int           iswctype  (wint_t WC, wctype_t Wct);
285 
286   /** Convert an uppercase letter to a corresponding lowercase letter.
287 
288     @param[in]  WC    The wide character to be converted.
289 
290     @return   If the argument is a wide character for which iswupper is TRUE
291               and there are one or more corresponding wide characters, as
292               specified by the current locale, for which iswlower is TRUE, the
293               towlower function returns one of the corresponding wide
294               characters (always the same one for any given locale); otherwise,
295               the argument is returned unchanged.
296   */
297   wint_t        towlower  (wint_t WC);
298 
299   /** Convert a lowercase letter to a corresponding uppercase letter.
300 
301     @param[in]  WC    The wide character to be converted.
302 
303     @return   If the argument is a wide character for which iswlower is TRUE
304               and there are one or more corresponding wide characters, as
305               specified by the current locale, for which iswupper is TRUE, the
306               towupper function returns one of the corresponding wide
307               characters (always the same one for any given locale); otherwise,
308               the argument is returned unchanged.
309   */
310   wint_t        towupper  (wint_t WC);
311 
312   /** Construct a value that describes a mapping between wide characters
313       identified by the string argument, S.
314 
315       The strings listed below are valid in all locales as the S argument to
316       the wctrans function.
317         - "tolower"
318         - "toupper"
319 
320     @param[in]  S   A pointer to a multibyte character string naming a
321                     mapping between wide characters.
322 
323     @return   If S identifies a valid mapping of wide characters in the current
324               locale, the wctrans function returns a nonzero value that is
325               valid as the second argument to the towctrans function;
326               otherwise, it returns zero.
327   */
328   wctrans_t     wctrans   (const char *S);
329 
330   /** Map the wide character WC using the mapping described by WTr. The current
331       locale will be the same as during the call to wctrans that returned
332       the value WTr.
333 
334     @param[in]  WC    The wide character to be converted.
335     @param[in]  WTr   A value describing a mapping of wide characters in the
336                       current locale.
337 
338     @return   Returns the mapped value of WC using the mapping selected by WTr.
339   */
340   wint_t        towctrans (wint_t WC, wctrans_t WTr);
341 __END_DECLS
342 
343 #endif    /* _WCTYPE_H_ */
344