Previous Page
Next Page

iswctype

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

"alnum"

iswctype(wc, wctype("alnum"))

isalnum(wc)

"alpha"

iswctype(wc, wctype("alpha"))

isalpha(wc)

"blank"

iswctype(wc, wctype("blank"))

isblank(wc)

"cntrl"

iswctype(wc, wctype("cntrl"))

iscntrl(wc)

"digit"

iswctype(wc, wctype("digit"))

isdigit(wc)

"graph"

iswctype(wc, wctype("graph"))

isgraph(wc)

"lower"

iswctype(wc, wctype("lower"))

islower(wc)

"print"

iswctype(wc, wctype("print"))

isprint(wc)

"punct"

iswctype(wc, wctype("punct"))

ispunct(wc)

"space"

iswctype(wc, wctype("space"))

isspace(wc)

"upper"

iswctype(wc, wctype("upper"))

isupper(wc)

"xdigit"

iswctype(wc, wctype("xdigit"))

isxdigit(wc)


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( ).

Example

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