function
<cwctype>
iswctype
int iswctype(wint_t c, wctype_t desc);
Check if wide character has property
Checks whether c has the property specified by desc.
A specific locale can accept multiple categories in which to classify its characters. At least the following categories are recognized by all locales:
string passed to wctype | description | equivalent function |
"alnum" | alphanumerical character | iswalnum |
"alpha" | letter character | iswalpha |
"blank" | blank character | iswblank |
"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 |
The setting of the LC_CTYPE locale category at the time of calling the function shall be the same as when wctype was called to obtain desc.
Parameters
- c
- Wide character to be checked, casted to a wint_t, or WEOF.
wint_t is an integral type.
- desc
- A value returned by a call to wctype (with the same LC_CTYPE locale category selected as in this call).
wctype_t is the scalar type used as return type for wctype.
Return Value
A value different from zero (i.e., true) if indeed c is has the property identified by desc. Zero (i.e., false) otherwise.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
/* iswctype example */
#include <stdio.h>
#include <wctype.h>
int main ()
{
int i=0;
wchar_t str[] = L"Test String.\n";
wchar_t c;
wctype_t check = wctype("lower");
wctrans_t trans = wctrans("toupper");
while (str[i])
{
c = str[i];
if (iswctype(c,check)) c = towctrans(c,trans);
putwchar (c);
i++;
}
return 0;
}
| |
Output:
See also
- wctype
- Return character property (function
)
- towctrans
- Convert using transformation (function
)