6.24.22 wctype Function
Returns a value that describes a class of wide characters and that can be used by
iswctype()
.
Include
<wctype.h>
Prototype
int wctype(const char * property);
Argument
-
property
- The wide character property to test for.
Return Value
Returns a value with type wctype_t
that describes a class of wide characters
identified by the string argument, property
Remarks
The string arguments are shown in the following table along with the wide character function which tests for the same wide character property.
String argument to wctype() | Function that tests for the same wide character property |
---|---|
"alnum" | iswalnum() |
"alpha" | iswalpha() |
"blank" | iswblank() |
"cntrl" | iswcntrl() |
"digit" | iswdigit() |
"graph" | iswgraph() |
"lower" | iswlower() |
"print" | iswprint() |
"punct" | iswpunct() |
"space" | iswspace() |
"upper" | iswupper() |
"xdigit" | isxdigit() |
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <wctype.h>
#include <stdio.h>
#include <stdbool.h>
int main(void)
{
wchar_t wStr[] = L"A string, 2 wide 4 some.\n";
wint_t wc;
unsigned idx = 0;
bool found = false;
do {
wc = wStr[idx];
if(iswctype(wc, wctype("digit"))) {
if( ! found)
printf("Found matching wide char at position: ");
printf("%s%u", found ? ", " : "", idx);
found = true;
}
idx++;
} while(wStr[idx]);
printf("\n");
}
Example Output
Found matching wide char at position: 10, 17