<wctype.h> provides wide-character classification (iswalpha, iswdigit, iswspace) and case conversion (towupper, towlower). These functions work on full Unicode via wchar_t, unlike <ctype.h> which handles only ASCII.
Results depend on locale; call setlocale(LC_ALL, "") for correct Unicode support.
This example classifies and case-converts wide characters in a string.
// compile: gcc -o wctypeexample wctypeexample.c // run: ./wctypeexample // description: classify and case-convert wide characters #include <wctype.h> #include <wchar.h> #include <locale.h> int main() { setlocale(LC_ALL, ""); const wchar_t* s = L"héLLo 42!"; for (const wchar_t* p = s; *p; p++) { wprintf(L"'%lc' alpha=%d digit=%d upper=%d upper→%lc\n", *p, iswalpha(*p) != 0, iswdigit(*p) != 0, iswupper(*p) != 0, towupper(*p)); } return 0; }
Character classification (return non-zero if true):
iswalpha(c): letteriswdigit(c): decimal digitiswalnum(c): alphanumericiswspace(c): whitespaceiswpunct(c): punctuationiswprint(c): printableiswcntrl(c): control characteriswupper(c): uppercaseiswlower(c): lowercaseiswxdigit(c): hex digitCase conversion:
towupper(c): convert to uppercasetowlower(c): convert to lowercasetowctrans(c, trans): apply locale-specific transformLocale-specific classification:
wctype(name): get character class by nameiswctype(c, type): test membership in class