411 REFERENCE · Wikibooks
C programming/wctype.h
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
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.bd wctype.h SUS wide-character classification and mapping utilities (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.
Character classification functions
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 iswalnum(wint_t wc); alphanumericint iswalpha(wint_t wc); alphabeticint iswblank(wint_t wc); blankint iswcntrl(wint_t wc); a control characterint iswctype(wint_t wc, wctype_t charclass); in charclassint iswdigit(wint_t wc); digitint iswgraph(wint_t wc); a visible characterint iswlower(wint_t wc); a lowercase letterint iswprint(wint_t wc); printableint iswpunct(wint_t wc); punctuationint iswspace(wint_t wc); white-spaceint iswupper(wint_t wc); an uppercase letterint iswxdigit(wint_t wc); a hexadecimal digit
Character mapping functions
These functions take a wide character, and apply some mapping to it.
Declaration Descriptionwint_t towctrans(wint_t ch, wctrans_t desc); Map ch according to the mapping descwint_t towlower(wint_t ch); If ch is an uppercase letter, map it to lowercase, otherwise return it unchangedwint_t towupper(wint_t ch); If ch is a lowercase letter, map it to uppercase, otherwise return it unchanged
Other functions
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")).The current Standard (C99 with Technical corrigenda TC1, TC2, and TC3 included) 3.61 MB. Pages 397, 398 and 400.
Declaration Descriptionwctrans_t wctrans(const char *charclass); Returns a character mapping which can be used with towctranswctype_t wctype(const char *property); Returns a character class which can be used with iswctype
References
deep