C <wctype.h> - iswctype() Function
The C <wctype.h> iswctype() function checks whether the wide character wc has the property specified by desc.
The setting of the LC_CTYPE category at the time of calling the function will be the same as when wctype() was called to obtain desc. A specific locale can accept multiple categories in which to classify its characters. At least the following properties supported in all C locales are as follows:
string passed to wctype() function | Description |
---|---|
"alnum" | alphanumerical character iswalnum() |
"alpha" | letter character iswalpha() |
"blank" | blank character iswblank() (C99) |
"cntrl" | control character iswcntrl() |
"digit" | decimal digit character iswdigit() |
"graph" | character with graphical representation iswgraph() |
"lower" | lowercase letter character iswlower() |
"print" | printable character iswprint() |
"punct" | punctuation character iswpunct() |
"space" | white-space character iswspace() |
"upper" | uppercase letter character iswupper() |
"xdigit" | hexadecimal digit character iswxdigit() |
Syntax
int iswctype(wint_t wc, wctype_t desc);
Parameters
wc |
Specify the wide character to be checked, casted to a wint_t value, or WEOF. |
desc |
Specify a LC_CTYPE category, obtained from a call to wctype(). |
Return Value
Returns a non-zero value if the character wc has the property identified by desc, zero otherwise.
Example:
The example below shows the usage of iswctype() function.
#include <stdio.h> #include <wchar.h> #include <wctype.h> int main (){ int i = 0; wchar_t str[50] = L"99HEllo@"; wchar_t c; //displaying the alphabetic //character in lower case wctype_t check = wctype("alpha"); wctrans_t trans = wctrans("tolower"); while (str[i]) { c = str[i]; if (iswctype(c, check)) { c = towctrans(c, trans); putwchar (c); } i++; } return 0; }
The output of the above code will be:
hello
❮ C <wctype.h> Library