Amendment 1 to ISO C90 defines functions to classify wide
characters. Although the original ISO C90 standard already defined
the type wchar_t
, no functions operating on them were defined.
The general design of the classification functions for wide characters
is more general. It allows extensions to the set of available
classifications, beyond those which are always available. The POSIX
standard specifies how extensions can be made, and this is already
implemented in the GNU C library implementation of the localedef
program.
The character class functions are normally implemented with bitsets, with a bitset per character. For a given character, the appropriate bitset is read from a table and a test is performed as to whether a certain bit is set. Which bit is tested for is determined by the class.
For the wide character classification functions this is made visible.
There is a type classification type defined, a function to retrieve this
value for a given class, and a function to test whether a given
character is in this class, using the classification value. 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
selected 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
if the property string is one of the known character
classes. In some situations it is desirable to construct the property
strings, and then it is 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 (iswdigit (*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.