Name

iswalpha

Synopsis

Ascertains whether a given wide character is a letter of the alphabet

#include <wctype.h>
intiswalpha( wint_t wc );

The iswalpha() function is the wide-character version of the isalpha() character classification function. It tests whether its character argument is a letter of the alphabet. If the character is alphabetic, iswalpha() returns a nonzero value (that is, true); if not, the function returns 0 (false).

Which characters are considered alphabetic depends on the current locale setting for the localization category LC_CTYPE, which you can query or change using the setlocale() function. In all locales, the iswalpha() classification is mutually exclusive with iswcntrl(), iswdigit(), iswpunct() and iswspace().

Accented characters, umlauts, and the like are considered alphabetic only in certain locales. Moreover, other locales may have wide characters that are alphabetic, but that are neither upper- nor lowercase, or both upper- and lowercase.

Example

wint_t wc; if ( setlocale( LC_CTYPE, "" ) == NULL) { fwprintf( stderr, L"Sorry, couldn't change to the system's native locale.\n"); return 1; } wprintf( L"The current locale for the 'isw ...' functions is '%s'.\n", setlocale(LC_CTYPE, NULL)); wprintf( L"Here is a table of the 'isw ...' values for the characters " L"from 128 to 255 in this locale:\n\n"); for ( wc = 128; wc < 255; ++wc ) // Loop iteration for each table row. { if ( (wc-128) % 24 == 0 ) // Repeat table header every 24 rows. { wprintf(L"Code char alnum ...

Get C in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.