This example uses wctype to return each standard property, and calls iswctype to test a wide character against each property.
#include <wctype.h> #include <stdio.h>
#define UPPER_LIMIT 0xFF
int main(void)
{
int wc;
for (wc = 0; wc <= UPPER_LIMIT; wc++) {
printf("%#4x ", wc);
printf("%c", iswctype(wc, wctype("print")) ? 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")) ? " X " : " ");
putchar('\n');
}
return 0;
/******************************************************************
The output should be similar to:
:
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
0x26 & G PU PR
0x27 ' G PU PR
0x28 ( G PU PR
0x29 ) G PU PR
0x2a * G PU PR
0x2b + G PU PR
0x2c , G PU PR
0x2d - G PU PR
0x2e . G PU PR
0x2f / G PU PR
0x30 0 AN D G PR X
0x31 1 AN D G PR X
0x32 2 AN D G PR X
0x33 3 AN D G PR X
0x34 4 AN D G PR X
0x35 5 AN D G PR X
:
******************************************************************/
}