c Programming/C Reference/wctype.h
In the programming language C, wctype.h is a header file in the standard library, containing various functions and macros for classifying and mapping wide characters. The corresponding header for dealing with (normal, non-wide) characters is <ctype.h>.
This header declares (from <wchar.h>) the wint_t and wctype_t types, and WEOF macro.[1] (wint_t is capable of storing any wide character or the value WEOF.) The type wctrans_t is also declared, which represents a mapping between characters.[1]
Contents |
Character classification functions [edit]
These functions return non-zero/zero depending on whether or not the argument is in a certain category according to the current locale. POSIX:2008 specifies alternate versions of the functions suffixed with _l which take a locale (locale_t) as an additional argument.
| Declaration | Return non-zero if ch is … |
|---|---|
int (wint_t wc); |
alphanumeric |
int (wint_t wc); |
alphabetic |
int (wint_t wc); |
blank |
int (wint_t wc); |
a control character |
int (wint_t wc, wctype_t charclass); |
in charclass |
int (wint_t wc); |
a decimal digit |
int (wint_t wc); |
a visible character |
int (wint_t wc); |
a lowercase letter |
int (wint_t wc); |
printable |
int (wint_t wc); |
punctuation |
int (wint_t wc); |
white-space |
int (wint_t wc); |
an uppercase letter |
int (wint_t wc); |
a hexadecimal digit |
Character mapping functions [edit]
These functions take a wide character, and apply some mapping to it.
| Declaration | Description |
|---|---|
wint_t (wint_t ch, wctrans_t desc); |
Map ch according to the mapping desc |
wint_t (wint_t ch); |
If ch is an uppercase letter, map it to lowercase, otherwise return it unchanged |
wint_t (wint_t ch); |
If ch is a lowercase letter, map it to uppercase, otherwise return it unchanged |
Other functions [edit]
These functions create values for use with other functions, from a string. Note that iswdigit(c) is the same as iswctype(c, wctype("digit")), and toupper(c) is the same as towctrans(c, wctrans("toupper")).[2]
| Declaration | Description |
|---|---|
wctrans_t (const char *charclass); |
Returns a character mapping which can be used with towctrans |
wctype_t (const char *property); |
Returns a character class which can be used with iswctype |
References [edit]
- ↑ a b : wide-character classification and mapping utilities – Base Definitions Reference, The Single UNIX® Specification, Issue 7 from The Open Group
- ↑ The current Standard (C99 with Technical corrigenda TC1, TC2, and TC3 included)PDF (3.61 MB). Pages 397, 398 and 400.