Pains were taken to eliminate any ASCII dependencies
from the definition of the character handling functions.
One notable result of this policy was the elimination of the function
isascii
,
both because of the name and because its function was hard to generalize.
Nevertheless,
the character functions are often most clearly explained in concrete terms,
so ASCII is used frequently to express examples.
Since these functions are often used primarily as macros,
their domain is restricted to the small positive integers representable in an
unsigned char
, plus the value of EOF
.
EOF
is traditionally -1,
but may be any negative integer,
and hence distinguishable from any valid character code.
These macros may thus be efficiently implemented by using the argument
as an index into a small array of attributes.
The Standard (§4.13.1) warns that names beginning with is
and to
,
when these are followed by lower-case letters,
are subject to future use in adding items to <ctype.h>
.
The definitions of printing character and control character have been generalized from ASCII.
Note that none of these functions returns
a nonzero value (true) for the argument value EOF
.
isalnum
function
isalpha
function
The Standard specifies that the set of letters,
in the default locale, comprises the
26 upper-case and 26 lower-case letters of the Latin (English)
alphabet.
This set may vary in a locale-specific fashion
(that is, under control of the setlocale
function, §4.4)
so long as
isupper(c)
implies isalpha(c)
islower(c)
implies isalpha(c)
isspace(c)
, ispunct(c)
, iscntrl(c)
, or isdigit(c)
implies !isalpha(c)
iscntrl
function
isdigit
function
isgraph
function
islower
function
isprint
function
ispunct
function
isspace
function
isspace
is widely used within the library as the working definition
of white space.
isupper
function
isxdigit
function
Earlier libraries had (almost equivalent) macros,
_tolower
and _toupper
,
for these functions.
The Standard now permits any library function to be additionally
implemented as a macro; the underlying function must still be present.
_toupper
and _tolower
are thus unnecessary and
were dropped as part of the general standardization of library macros.
tolower
function
toupper
function