Name
iswalnum
Synopsis
Ascertains whether a given wide character is alphanumeric
#include <wctype.h> intiswalnum
( wint_twc
);
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:
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.