Ascertains whether a given wide character is alphanumeric #include <wctype.h> int iswalnum ( wint_t wc ); The iswalnum( ) function is the wide-character version of the isalnum( ) character classification function. It tests whether its character argument is alphanumeric; that is, whether the character is either a letter of the alphabet or a digit. If the character is alphanumeric, iswalnum( ) returns a nonzero value (that is, TRue); if not, the function returns 0 (false). Which characters are considered alphabetic or numeric depends on the current locale setting for the localization category LC_CTYPE, which you can query or change using the setlocale( ) function. In general, iswalnum( ) is true for all characters for which either iswalpha( ) or iswdigit( ) is true. Example
wint_t wc, i;
int j, dummy;
setlocale( LC_CTYPE, "" );
wprintf( L"\nThe current locale for the 'is ...' functions is '%s'.\n",
setlocale( LC_CTYPE, NULL ) );
wprintf( L"These are the alphanumeric wide characters"
" in this locale:\n\n" );
for ( wc = 0, i = 0; wc < 1024; wc++ )
if ( iswalnum( wc ) )
{
if ( i % 25 == 0 )
{
wprintf( L"... more ...\n" );
dummy = getchar( ); // Wait a moment before printing more
wprintf( L"Wide character Code\n" );
wprintf( L"-----------------------\n" );
}
wprintf( L"%5lc %4lu\n", wc, wc );
i++;
}
wprintf( L"-----------------------\n" );
return 0;
Here are samples from the output of this code. Which characters can be displayed correctly on the screen depends on the font used:
The current locale for the 'is ...' functions is 'de_DE.UTF-8'.
These are the alphanumeric wide characters in this locale:
Wide character Code
-----------------------
0 48
1 49
2 50
...
See Alsoiswalpha( ) and iswdigit( ); the corresponding function for byte characters, isalnum( ); iswblank( ), iswcntrl( ), iswgraph( ), iswlower( ), iswprint( ), iswpunct( ), iswspace( ), iswupper( ), iswxdigit( ), setlocale( ); the extensible wide-character classification function, iswctype( ) |