Format
#include <wctype.h> int iswctype(wint_t wc, wctype_t wc_prop);
Language Level: ANSI
Threadsafe: Yes.
Description
The iswctype() function determines whether the wide character wc has the property wc_prop. If the value of wc is neither WEOF nor any value of the wide characters that corresponds to a multibyte character, the behavior is undefined. If the value of wc_prop is incorrect (that is, it is not obtained by a previous call to the wctype() function, or wc_prop has been invalidated by a subsequent call to the setlocale() function), the behavior is undefined.
If the program is compiled with LOCALETYPE(*LOCALEUCS2) or LOCALETYPE(*LOCALEUTF) , the wide character properties are those defined by the LC_UNI_CTYPE category of the current locale.
Return Value
The iswctype() function returns true if the value of the wide character wc has the property wc_prop.
The following strings, alnum through to xdigit are reserved for the standard character classes. The functions are shown as follows with their equivalent isw*() function:
iswctype(wc, wctype("alnum")); /* is equivalent to */ iswalnum(wc); iswctype(wc, wctype("alpha")); /* is equivalent to */ iswalpha(wc); iswctype(wc, wctype("cntrl")); /* is equivalent to */ iswcntrl(wc); iswctype(wc, wctype("digit")); /* is equivalent to */ iswdigit(wc); iswctype(wc, wctype("graph")); /* is equivalent to */ iswgraph(wc); iswctype(wc, wctype("lower")); /* is equivalent to */ iswlower(wc); iswctype(wc, wctype("print")); /* is equivalent to */ iswprint(wc); iswctype(wc, wctype("punct")); /* is equivalent to */ iswpunct(wc); iswctype(wc,wctype("space")); /* is equivalent to */ iswspace(wc); iswctype(wc, wctype("upper")); /* is equivalent to */ iswupper(wc); iswctype(wc, wctype("xdigit")); /* is equivalent to */ iswxdigit(wc);
Example that uses iswctype()
#include <stdio.h> #include <wctype.h> int main(void) { int wc; for (wc=0; wc <= 0xFF; wc++) { printf("%3d", wc); printf(" %#4x ", wc); printf("%3s", iswctype(wc, wctype("alnum")) ? "AN" : " "); printf("%2s", iswctype(wc, wctype("alpha")) ? "A" : " "); printf("%2s", iswctype(wc, wctype("cntrl")) ? "C" : " "); printf("%2s", iswctype(wc, wctype("digit")) ? "D" : " "); printf("%2s", iswctype(wc, wctype("graph")) ? "G" : " "); printf("%2s", iswctype(wc, wctype("lower")) ? "L" : " "); printf(" %c", iswctype(wc, wctype("print")) ? wc : ' '); printf("%3s", iswctype(wc, wctype("punct")) ? "PU" : " "); printf("%2s", iswctype(wc, wctype("space")) ? "S" : " "); printf("%3s", iswctype(wc, wctype("print")) ? "PR" : " "); printf("%2s", iswctype(wc, wctype("upper")) ? "U" : " "); printf("%2s", iswctype(wc, wctype("xdigit")) ? "X" : " "); putchar('\n'); } }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.