Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
#include <wctype.h>
int iswctype(wint_t wc, wctype_t wc_prop);
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 character that corresponds to a multibyte character, the behavior is undefined. If the value of wc_prop is not valid (that is, not obtained by a previous call to wctype(), or wc_prop has been invalidated by a subsequent call to setlocale() that has affected category LC_CTYPE), the behavior is undefined.
These twelve strings are reserved for the standard (basic) character classes: alnum, alpha, blank, cntrl, digit, graph, lower, print, punct, space, upper, and xdigit.
iswctype(wc, wctype("alnum")); - iswalnum(wc);
iswctype(wc, wctype("alpha")); - iswalpha(wc);
iswctype(wc, wctype("blank")); - iswblank(wc);
iswctype(wc, wctype("cntrl")); - iswcntrl(wc);
iswctype(wc, wctype("digit")); - iswdigit(wc);
iswctype(wc, wctype("graph")); - iswgraph(wc);
iswctype(wc, wctype("lower")); - iswlower(wc);
iswctype(wc, wctype("print")); - iswprint(wc);
iswctype(wc, wctype("punct")); - iswpunct(wc);
iswctype(wc, wctype("space")); - iswspace(wc);
iswctype(wc, wctype("upper")); - iswupper(wc);
iswctype(wc, wctype("xdigit")); - iswxdigit(wc);
iswctype() returns nonzero (true) if the wide character wc has the property wc_prop.
⁄* CELEBI07
This example test various wide characters for certain properties and
prints the result.
*⁄
#include <stdio.h>
#include <wchar.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');
}
}