#include <wctype.h>
|
int
iswctype (wint_t wch, wctype_t chcl); |
The iswctype() function tests whether the wide-character wch belongs to the character class/category chcl.
The result of this function is undefined unless the argument is WEOF or a valid wchar_t value.
The functionality of this API is independent of the program’s current locale and so it returns non-zero for all the characters given in ’wch’(of various locales supported) that belong to the class chcl(see _ctype.h for definition of values that can be used to specify category), irrespective of the locale they belong to.
For example: digits 0 to 9 would belong to _CTYPE_D class (i.e. class digit), and a to z would belong to _CTYPE_L class (i.e. class lower).
#include<wctype.h> //iswctype() #include<stdio.h> //printf() int test_iswctype() { struct st { int input; int category; }; struct st arr[]={ {0xFF21, _CTYPE_A}, {0x0040, _CTYPE_P}, {0x007F, _CTYPE_C}, {0xFF10,_CTYPE_G}, {0x007A, _CTYPE_U}, {0xFF6F, _CTYPE_D}, {0xFF10, _CTYPE_S}, }; int i = 0; int size = 7; for( i=0; i<size; i++) { //call to the API with the values in the arr[] int ret = iswctype(arr[i].input, arr[i].category); if( (!ret) != 0 ) { printf("\n0x%x not from this category ", arr[i].input); } else { printf("\n0x%x from this category", arr[i].input); } } printf("\n"); }
Output
0xFF21 from this category 0x0040 from this category 0x007F from this category 0xFF10 from this category 0x007A not from this category 0xFF6F not from this category 0xFF10 not from this category
© 2005-2007 Nokia |