Syntax
#include <wctype.h> int iswctype(wint_t wc, wctype_t wc_prop);Description
iswctype determines whether the wide character wc has the property wc_prop. It is similar in function to the iswalnum through isxdigit functions, but with iswctype you can specify the property to check for, or check for a property other than the standard ones.
You must obtain the wc_prop value from a call to wctype. If you do not, or if the LC_CTYPE category of the locale was modified after you called wctype, the behavior of iswctype is undefined.
The value of wc must be representable as an unsigned wchar_t, or WEOF.
The following strings correspond to the standard (basic) character classes
or properties: cols='15 15 15 15'.
┌──────────────────────────────────────────────────────────────────────────────┐
│ " │
│ "alnum" │
│ "alpha" │
│ "blank" " │
├──────────────────────────────────────────────────────────────────────────────┤
│ " │
│ "cntrl" │
│ "digit" │
│ "graph" " │
├──────────────────────────────────────────────────────────────────────────────┤
│ " │
│ "lower" │
│ "print" │
│ "punct" " │
├──────────────────────────────────────────────────────────────────────────────┤
│ " │
│ "space" │
│ "upper" │
│ "xdigit" " │
└──────────────────────────────────────────────────────────────────────────────┘
The following shows calls to wctype and indicates the equivalent isw* function:
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); */
Returns
iswctype returns a nonzero value if the wide character has the property tested for. If the value for wc or wc_prop is not valid, the behavior is undefined.
This example analyzes all characters between 0x0 and 0xFF. The output of this example is a 256-line table showing the characters from 0 to 255, indicating whether they have the properties tested for.
#include <locale.h>
#include <stdio.h>
#include <wctype.h>
#define UPPER_LIMIT 0xFF
int main(void)
{
wint_t wc;
setlocale(LC_ALL, "En_US");
for (wc = 0; wc <= UPPER_LIMIT; wc++) {
printf("%#4x ", wc);
printf("%lc", iswctype(wc, wctype("print")) ? (wchart)wc : ' ');
printf("%s", iswctype(wc, wctype("alnum")) ? " AN" : " ");
printf("%s", iswctype(wc, wctype("alpha")) ? " A " : " ");
printf("%s", iswctype(wc, wctype("blank")) ? " B " : " ");
printf("%s", iswctype(wc, wctype("cntrl")) ? " C " : " ");
printf("%s", iswctype(wc, wctype("digit")) ? " D " : " ");
printf("%s", iswctype(wc, wctype("graph")) ? " G " : " ");
printf("%s", iswctype(wc, wctype("lower")) ? " L " : " ");
printf("%s", iswctype(wc, wctype("punct")) ? " PU" : " ");
printf("%s", iswctype(wc, wctype("space")) ? " S " : " ");
printf("%s", iswctype(wc, wctype("print")) ? " PR" : " ");
printf("%s", iswctype(wc, wctype("upper")) ? " U " : " ");
printf("%s", iswctype(wc, wctype("xdigit")) ? " H " : " ");
putchar('\n');
}
return 0;
/****************************************************************************
The output should be similar to :
:
0x1e C
0x1f C
0x20 B S PR
0x21 ! G PU PR
0x22 " G PU PR
0x23 # G PU PR
0x24 $ G PU PR
0x25 % G PU PR
:
0x30 0 AN D G PR H
0x31 1 AN D G PR H
0x32 2 AN D G PR H
0x33 3 AN D G PR H
0x34 4 AN D G PR H
0x35 5 AN D G PR H
:
0x43 C AN A G PR U H
0x44 D AN A G PR U H
0x45 E AN A G PR U H
0x46 F AN A G PR U H
0x47 G AN A G PR U
:
****************************************************************************/
}
Related Information