Previous Page
Next Page


Ascertains whether a given wide character fits a given description

#include <wctype.h>
int iswctype ( wint_t wc , wctype_t description  );

The iswctype( ) function tests whether the wide character passed as its first argument falls in the category indicated by the second argument. The value of the second argument, with the special-purpose type wctype_t, is obtained by calling the function wctype( ) with a string argument that names a property of characters in the current locale. In the default locale, C, characters can have the properties listed in Table 17-4.

Table 17-4. Wide character properties

Character property

iswctype( ) call

Equivalent single function call


iswctype(wc, wctype("alnum"))



iswctype(wc, wctype("alpha"))



iswctype(wc, wctype("blank"))



iswctype(wc, wctype("cntrl"))



iswctype(wc, wctype("digit"))



iswctype(wc, wctype("graph"))



iswctype(wc, wctype("lower"))



iswctype(wc, wctype("print"))



iswctype(wc, wctype("punct"))



iswctype(wc, wctype("space"))



iswctype(wc, wctype("upper"))



iswctype(wc, wctype("xdigit"))


If the wide character argument has the property indicated, iswctype( ) returns a nonzero value (that is, TRue); if not, the function returns 0 (false). Thus the call iswctype(wc, wctype("upper")) is equivalent to iswupper(wc).

The result of an iswctype( ) function call depends on the current locale setting for the localization category LC_CTYPE, which you can query or change using the setlocale( ) function. Furthermore, additional property strings are defined in other locales. For example, in a Japanese locale, the call iswctype(wc, wctype("jkanji")) can be used to distinguish kanji from katakana or hiragana characters. You must not change the LC_CTYPE setting between the calls to wctype( ) and iswctype( ).


wint_t wc = L'ß';

setlocale( LC_CTYPE, "de_DE.UTF-8" );
if ( iswctype( wc, wctype( "alpha" )) )
  if ( iswctype( wc, wctype( "lower" ) ))
    wprintf( L"The character %lc is lowercase.\n", wc );
  if ( iswctype( wc, wctype( "upper" ) ))
    wprintf( L"The character %lc is uppercase.\n", wc );

See Also

wctype( ), iswalnum( ), iswalpha( ), iswblank( ), iswcntrl( ), iswdigit( ), iswgraph( ), iswlower( ), iswprint( ), iswpunct( ), iswspace( ), iswupper( ), iswxdigit( )

Previous Page
Next Page