C++ <cwctype> - wctype() Function
The C++ <cwctype> wctype() function returns a value of type wctype_t that corresponds to the character category specified by property.
The value returned by this function depends on the LC_CTYPE category selected. A specific locale can accept multiple categories in which to classify its characters.
Syntax
wctype_t wctype (const char* property);
Parameters
property |
Specify a C string holding the name of the desired category. The values of property supported in all C locales are as follows:
|
Return Value
Returns a value of type wctype_t identifying a specific character category. This value is locale-dependent. Returns zero if property does not name a category supported by the current C locale.
Example:
The example below shows the usage of wctype() function.
#include <cstdio> #include <cwchar> #include <cwctype> int main (){ int i = 0; wchar_t str[50] = L"99HEllo@"; wchar_t c; //displaying the alphabetic //character in upper case wctype_t check = wctype("alpha"); wctrans_t trans = wctrans("toupper"); 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++ <cwctype> Library