The second amendment to ISO C89 defines functions to classify wide
character. Although the original ISO C89 standard already defined
the type wchar_t
but no functions operating on them were defined.
The general design of the classification functions for wide characters
is more general. It allows to extend the set of available
classification beyond the set which is always available. The POSIX
standard specifies a way how the extension can be done and this is
already implemented in the GNU C library implementation of the
localedef
program.
The character class functions are normally implemented using bitsets. I.e., for the character in question the appropriate bitset is read from a table and a test is performed whether a certain bit is set in this bitset. Which bit is tested for is determined by the class.
For the wide character classification functions this is made visible.
There is a type representing the classification, a function to retrieve
this value for a specific class, and a function to test using the
classification value whether a given character is in this class. On top
of this the normal character classification functions as used for
char
objects can be defined.
wctype_t
can hold a value which represents a character class.
The only defined way to generate such a value is by using the
wctype
function.
wctype
returns a value representing a class of wide
characters which is identified by the string property. Beside
some standard properties each locale can define its own ones. In case
no property with the given name is known for the current locale for the
LC_CTYPE
category the function returns zero.
The properties known in every locale are:
@multitable @columnfractions .25 .25 .25 .25
"alnum"
@tab "alpha"
@tab "cntrl"
@tab "digit"
"graph"
@tab "lower"
@tab "print"
@tab "punct"
"space"
@tab "upper"
@tab "xdigit"
This function is declared in `wctype.h'.
wctype
.
This function is declared in `wctype.h'.
wctype
is the property string is one of the known character
classes. In some situations it is desirable to construct the property
string and then it gets important that wctype
can also handle the
standard classes.
iswalpha
or iswdigit
is true of a character, then iswalnum
is also
true.
This function can be implemented using
iswctype (wc, wctype ("alnum"))It is declared in `wctype.h'.
iswlower
or iswupper
is true of a character, then
iswalpha
is also true.
In some locales, there may be additional characters for which
iswalpha
is true--letters which are neither upper case nor lower
case. But in the standard "C"
locale, there are no such
additional characters.
This function can be implemented using
iswctype (wc, wctype ("alpha"))It is declared in `wctype.h'.
iswctype (wc, wctype ("cntrl"))It is declared in `wctype.h'.
n = 0; while (iswctype (*wc)) { n *= 10; n += *wc++ - L'0'; }This function can be implemented using
iswctype (wc, wctype ("digit"))It is declared in `wctype.h'.
iswctype (wc, wctype ("graph"))It is declared in `wctype.h'.
iswctype (wc, wctype ("lower"))It is declared in `wctype.h'.
iswctype (wc, wctype ("print"))It is declared in `wctype.h'.
iswctype (wc, wctype ("punct"))It is declared in `wctype.h'.
"C"
locale, iswspace
returns true for only the standard
whitespace characters:
L' '
L'\f'
L'\n'
L'\r'
L'\t'
L'\v'
iswctype (wc, wctype ("space"))It is declared in `wctype.h'.
iswctype (wc, wctype ("upper"))It is declared in `wctype.h'.
iswctype (wc, wctype ("xdigit"))It is declared in `wctype.h'.
Go to the first, previous, next, last section, table of contents.