Standards
Standards / Extensions |
C or C++ |
Dependencies |
ISO C Amendment
XPG4
XPG4.2
C99
Single UNIX Specification, Version 3
|
both |
|
Format
#include <wctype.h>
int iswalnum(wint_t wc);
int iswalpha(wint_t wc);
int iswcntrl(wint_t wc);
int iswdigit(wint_t wc);
int iswgraph(wint_t wc);
int iswlower(wint_t wc);
int iswprint(wint_t wc);
int iswpunct(wint_t wc);
int iswspace(wint_t wc);
int iswupper(wint_t wc);
int iswxdigit(wint_t wc);
General description
The functions
listed above, which are all declared in wctype.h, test a given wide
integer value. These functions are sensitive to locale. For locale
descriptions, see “Internationalization: Locales and Character Sets”
in
z/OS XL C/C++ Programming Guide.
Here are descriptions of each function in this group.
- iswalnum()
- Test for a wide alphanumeric character, as defined in the alnum locale
source file and in the alnum class of the LC_CTYPE
category of the current locale.
- iswalpha()
- Test for a wide
alphabetic character, as defined in the alpha locale
source file and in the alpha class of the LC_CTYPE
category of the current locale.
- iswcntrl()
- Test for a wide
control character, as defined in the cntrl locale
source file and in the cntrl class of the LC_CTYPE
category of the current locale.
- iswdigit()
- Test for a wide
decimal-digit character: 0 through 9, as defined in the digit locale
source file and in the digit class of the LC_CTYPE
category of the current locale.
- iswgraph()
- Test for a wide
printing character, not a space. as defined in the graph locale
source file and in the graph class of the LC_CTYPE
category of the current locale.
- iswlower()
- Test for a wide
lowercase letter, as defined in the lower locale
source file and in the lower class of the LC_CTYPE
category of the current locale.
- iswprint()
- Test
for any wide printing character, as defined in the print locale
source file and in the print class of the LC_CTYPE
category of the current locale.
- iswpunct()
- Test for a wide
nonalphanumeric, nonspace character, as defined in the punct locale
source file and in the punct class of the LC_CTYPE
category of the current locale.
- iswspace()
- Test for a wide
white space character, as defined in the space locale
source file and in the space class of the LC_CTYPE
category of the current locale.
- iswupper()
- Test for a wide
uppercase letter, as defined in the upper locale
source file and in the upper class of the LC_CTYPE
category of the current locale.
- iswxdigit()
- Test for a
wide hexadecimal digit 0 through 9, a through f, or A through F, as
defined in the xdigit locale source file and in the xdigit class
of the LC_CTYPE category of the current locale.
The behavior of these wide-character function
are affected by the LC_CTYPE category of the current locale. The space,
uppercase, and lowercase characters can be redefined by their respective
class of the LC_CTYPE in the current locale. If you change the category,
undefined results can occur.
Returned value
If the wide integer satisfies
the test value, these functions return nonzero.
If the wide
integer does not satisfy the test value, these functions return 0.
The
value for wc must be representable as a
wide unsigned character. WEOF is a valid input value.
Example
CELEBI06 ⁄* CELEBI06
This example tests for various wide integer values and prints a result.
*⁄
#include <stdio.h>
#include <wctype.h>
int main(void)
{
wint_t wc;
for (wc=0; wc <= 0xFF; wc++) {
printf("%3d", wc);
printf(" %#4x ", wc);
printf("%3s", iswalnum(wc) ? "AN" : " ");
printf("%2s", iswalpha(wc) ? "A" : " ");
printf("%2s", iswcntrl(wc) ? "C" : " ");
printf("%2s", iswdigit(wc) ? "D" : " ");
printf("%2s", iswgraph(wc) ? "G" : " ");
printf("%2s", iswlower(wc) ? "L" : " ");
printf(" %c", iswprint(wc) ? wc : ' ');
printf("%3s", iswpunct(wc) ? "PU" : " ");
printf("%2s", iswspace(wc) ? "S" : " ");
printf("%3s", iswprint(wc) ? "PR" : " ");
printf("%2s", iswupper(wc) ? "U" : " ");
printf("%2s", iswxdigit(wc) ? "X" : " ");
putchar('\n');
}
}