Syntax
#include <wctype.h> /* test for: */ int iswalnum(wint_t wc); /* wide alphanumeric character */ int iswalpha(wint_t wc); /* wide alphabetic character */ int iswcntrl(wint_t wc); /* wide control character */ int iswdigit(wint_t wc); /* wide decimal digit */ int iswgraph(wint_t wc); /* wide printable character, excluding space */ int iswlower(wint_t wc); /* wide lowercase character */ int iswprint(wint_t wc); /* wide printable character, including space */ int iswpunct(wint_t wc); /* wide punctuation character, excluding space */ int iswspace(wint_t wc); /* wide whitespace character */ int iswupper(wint_t wc); /* wide uppercase character */ int iswxdigit(wint_t wc); /* wide hexadecimal digit */Description
These functions test a given wide integer value wc to determine whether it has a certain property as defined by the LC_CTYPE category of your current locale. The value of wc must be representable as a wchar_t or WEOF.
The functions test for the following:
iswalnum
These functions return a nonzero value if the wide integer satisfies the test value; 0 if it does not.
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 and indicates if the characters 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", iswprint(wc) ? (wchar_t)wc : " "); printf("%s", iswalnum(wc) ? " AN" : " "); printf("%s", iswalpha(wc) ? " A " : " "); printf("%s", iswcntrl(wc) ? " C " : " "); printf("%s", iswdigit(wc) ? " D " : " "); printf("%s", iswgraph(wc) ? " G " : " "); printf("%s", iswlower(wc) ? " L " : " "); printf("%s", iswpunct(wc) ? " PU" : " "); printf("%s", iswspace(wc) ? " S " : " "); printf("%s", iswprint(wc) ? " PR" : " "); printf("%s", iswupper(wc) ? " U " : " "); printf("%s", iswxdigit(wc) ? " H " : " "); putchar('\n'); } return 0;
/**************************************************************************** The output should be similar to : : 0x20 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 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 0x36 6 AN D G PR H 0x37 7 AN D G PR H 0x38 8 AN D G PR H 0x39 9 AN D G PR H : ****************************************************************************/ }Related Information