Indicates if a wide character has a specified property. Format #include <wctype.h> (ISO C) #include <wchar.h> (XPG4) int iswctype (wint_t wc, wctype_t wc_prop);
1 – Arguments
wc An object of type wint_t. The value of wc must be representable as a valid wide-character code in the current locale, or must equal the value of the macro WEOF. If it has any other value, the behavior is undefined. wc_prop A valid property name in the current locale. This is set up by calling the wctype function.
2 – Description
The iswctype function tests whether wc has the character-class property wc_prop. Set wc_prop by calling the wctype function. See also wctype.
3 – Return Values
nonzero If the character has the property wc_prop. 0 If the character does not have the property wc_prop.
4 – Example
#include <locale.h> #include <wchar.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> /* This test will set up the "upper" character class using */ /* wctype() and then verify whether the characters 'a' and 'A' */ /* are members of this class */ #include <stdlib.h> main() { wchar_t w_char1, w_char2; wctype_t ret_val; char *char1 = "a"; char *char2 = "A"; ret_val = wctype("upper"); /* Convert char1 to wide-character format - w_char1 */ if (mbtowc(&w_char1, char1, 1) == -1) { perror("mbtowc"); exit(EXIT_FAILURE); } if (iswctype((wint_t) w_char1, ret_val)) printf("[%C] is a member of the character class upper\n", w_char1); else printf("[%C] is not a member of the character class upper\n", w_char1); /* Convert char2 to wide-character format - w_char2 */ if (mbtowc(&w_char2, char2, 1) == -1) { perror("mbtowc"); exit(EXIT_FAILURE); } if (iswctype((wint_t) w_char2, ret_val)) printf("[%C] is a member of the character class upper\n", w_char2); else printf("[%C] is not a member of the character class upper\n", w_char2); } Running the example program produces the following result: [a] is not a member of the character class upper [A] is a member of the character class upper