1 /* Wide character classification and mapping utilities <wctype.h>
2 
3    This file is part of the Public Domain C Library (PDCLib).
4    Permission is granted to use, modify, and / or redistribute at will.
5 */
6 
7 #ifndef _PDCLIB_WCTYPE_H
8 #define _PDCLIB_WCTYPE_H _PDCLIB_WCTYPE_H
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #include "pdclib/_PDCLIB_internal.h"
15 
16 typedef _PDCLIB_wint_t wint_t;
17 typedef int wctrans_t;
18 typedef int wctype_t;
19 
20 #ifndef _PDCLIB_WEOF_DEFINED
21 #define _PDCLIB_WEOF_DEFINED _PDCLIB_WEOF_DEFINED
22 #define WEOF (wint_t)-1
23 #endif
24 
25 /* Wide character classification functions */
26 
27 /* Returns iswalpha( wc ) || iswdigit( wc ) */
28 _PDCLIB_PUBLIC int iswalnum( wint_t wc );
29 
30 /* Returns true for wide characters for which either isupper( wc ) or
31    islower( wc ) is true, as well as a set of locale-specific wide
32    characters which are neither control characters, digits, punctuation,
33    or whitespace.
34 */
35 _PDCLIB_PUBLIC int iswalpha( wint_t wc );
36 
37 /* Returns true if the character iswspace() and used for separating words
38    within a line of text. In the "C" locale, only L' ' and L'\t' are
39    considered blanks.
40 */
41 _PDCLIB_PUBLIC int iswblank( wint_t wc );
42 
43 /* Returns true if the wide character is a control character. */
44 _PDCLIB_PUBLIC int iswcntrl( wint_t wc );
45 
46 /* Returns true if the wide character is a decimal digit. Locale-
47    independent. */
48 _PDCLIB_PUBLIC int iswdigit( wint_t wc );
49 
50 /* Returns iswprint( wc ) && ! iswspace( wc ).
51    NOTE: This definition differs from that of isgraph() in <ctype.h>,
52          which considers only ' ', not all isspace() characters.
53 */
54 _PDCLIB_PUBLIC int iswgraph( wint_t wc );
55 
56 /* Returns true for lowerspace wide characters, as well as a set of
57    locale-specific wide characters which are neither control charcters,
58    digits, punctuation, or whitespace.
59 */
60 _PDCLIB_PUBLIC int iswlower( wint_t wc );
61 
62 /* Returns true for every printing wide character. */
63 _PDCLIB_PUBLIC int iswprint( wint_t wc );
64 
65 /* Returns true for a locale-specific set of punctuation characters that
66    are neither whitespace nor alphanumeric.
67 */
68 _PDCLIB_PUBLIC int iswpunct( wint_t wc );
69 
70 /* Returns true for a locale-specific set of whitespace characters that
71    are neither alphanumeric, graphic, or punctuation.
72 */
73 _PDCLIB_PUBLIC int iswspace( wint_t wc );
74 
75 /* Returns true for upperspace wide characters, as well as a set of
76    locale-specific wide characters which are neither control charcters,
77    digits, punctuation, or whitespace.
78 */
79 _PDCLIB_PUBLIC int iswupper( wint_t wc );
80 
81 /* Returns true if the wide character is a hexadecimal digit. Locale-
82    independent. */
83 _PDCLIB_PUBLIC int iswxdigit( wint_t wc );
84 
85 /* Extensible wide character classification functions */
86 
87 /* Returns true if the wide character wc has the property described by
88    desc (which was retrieved by a previous call to wctype() without
89    changing the LC_CTYPE locale setting between the two calls).
90 */
91 _PDCLIB_PUBLIC int iswctype( wint_t wc, wctype_t desc );
92 
93 /* Returns a description object for a named character property, to be
94    used as parameter to the iswctype() function. Supported property
95    names are:
96    "alnum" -- alphanumeric, as per iswalnum()
97    "alpha" -- alphabetic, as per iswalpha()
98    "blank" -- blank, as per iswblank()
99    "cntrl" -- control, as per iswcntrl()
100    "digit" -- decimal digit, as per iswdigit()
101    "graph" -- graphic, as per iswgraph()
102    "lower" -- lowercase, as per iswlower()
103    "print" -- printing, as per iswprint()
104    "punct" -- punctuation, as per iswprint()
105    "space" -- whitespace, as per iswspace()
106    "upper" -- uppercase, as per iswupper()
107    "xdigit" -- hexadecimal digit, as per iswxdigit()
108    For unsupported properties, the function returns zero.
109 */
110 _PDCLIB_PUBLIC wctype_t wctype( const char * property );
111 
112 /* Wide character case mapping utilities */
113 
114 /* Converts an uppercase letter to a corresponding lowercase letter. Input for
115    which no corresponding lowercase letter exists remains unchanged.
116 */
117 _PDCLIB_PUBLIC wint_t towlower( wint_t wc );
118 
119 /* Converts a lowercase letter to a corresponding uppercase letter. Input for
120    which no corresponding uppercase letter exists remains unchanged.
121 */
122 _PDCLIB_PUBLIC wint_t towupper( wint_t wc );
123 
124 /* Extensible wide character case mapping utilities */
125 
126 /* Converts the wide character wc according to the transition described
127    by desc (which was retrieved by a previous call to wctrans() without
128    changing the LC_CTYPE locale setting between the two calls).
129 */
130 _PDCLIB_PUBLIC wint_t towctrans( wint_t wc, wctrans_t desc );
131 
132 /* Returns a description object for a named character transformation, to
133    be used as parameter to the towctrans() function. Supported transformation
134    properties are:
135    "tolower" -- lowercase mapping, as per towlower()
136    "toupper" -- uppercase mapping, as per towupper()
137    For unsupported properties, the function returns zero.
138 */
139 _PDCLIB_PUBLIC wctrans_t wctrans( const char * property );
140 
141 /* Extension hook for downstream projects that want to have non-standard
142    extensions to standard headers.
143 */
144 #ifdef _PDCLIB_EXTEND_WCTYPE_H
145 #include _PDCLIB_EXTEND_WCTYPE_H
146 #endif
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
152 #endif
153