CTYPE(3C) INTERACTIVE UNIX System CTYPE(3C)
NAME
ctype: isdigit, isxdigit, islower, isupper, isalpha, isal-
num, isspace, iscntrl, ispunct, isprint, isgraph, isascii,
tolower, toupper, toascci, _tolower, _toupper, setchrclass -
character handling
SYNOPSIS
#include <ctype.h>
int isdigit (c);
int c;
. . .
tolower(c)
int c;
. . .
int setchrclass (chrclass)
char *chrclass;
DESCRIPTION
The character classification macros listed below return
nonzero for true, zero for false. isascii is defined on all
integer values; the rest are defined on valid members of the
character set and on the single value EOF [see stdio(3S)]
(guaranteed not to be a character set member).
isdigit tests for the digits 0 through 9.
isxdigit tests for any character for which isdigit is
true or for the letters a through f or A
through F.
islower tests for any lowercase letter as defined by
the character set.
isupper tests for any uppercase letter as defined by
the character set.
isalpha tests for any character for which islower or
isupper is true and possibly any others as
defined by the character set.
isalnum tests for any character for which isalpha or
isdigit is true.
isspace tests for a space, horizontal-tab, carriage
return, newline, vertical-tab, or form-feed.
iscntrl tests for ``control characters'' as defined
by the character set.
Rev. C Software Development Set Page 1
CTYPE(3C) INTERACTIVE UNIX System CTYPE(3C)
ispunct tests for any character other than the ones
for which isalnum, iscntrl, or isspace is
true or space.
isprint tests for a space or any character for which
isalnum or ispunct is true or other ``print-
ing character'' as defined by the character
set.
isgraph tests for any character for which isprint is
true, except for space.
isascii tests for an ASCII character (a non-negative
number less than 0200).
The conversion functions and macros translate a character
from lowercase (uppercase) to uppercase (lowercase).
tolower if the character is one for which isupper is
true and there is a corresponding lowercase
character, tolower returns the corresponding
lowercase character. Otherwise, the charac-
ter is returned unchanged.
toupper if the character is one for which islower is
true and there is a corresponding uppercase
character, toupper returns the corresponding
uppercase character. Otherwise, the charac-
ter is returned unchanged.
toascii turns off the bits that are not part of the
ASCII character set.
_tolower returns the lowercase representation of a
character for which isupper is true, other-
wise undefined.
_toupper returns the uppercase representation of a
character for which islower is true, other-
wise undefined.
The conversion macros have the same functionality of the
functions on valid input, but the macros are faster because
they do not do range checking.
All the character classification macros and the conversion
functions and macros do a table lookup.
setchrclass initializes the table used by these functions
and macros to a specific character classification set.
setchrclass uses the value of its argument or the value of
the environment variable CHRCLASS as the name of the
datafile containing the information for the desired
Rev. C Software Development Set Page 2
CTYPE(3C) INTERACTIVE UNIX System CTYPE(3C)
character set. These datafiles are searched for in the spe-
cial directory /lib/chrclass.
If chrclass is (char *)0, the value of the environment vari-
able CHRCLASS is used. If CHRCLASS is not set or is unde-
fined, the table retains its current value, which at ini-
tialization time is ascii.
FILES
/lib/chrclass - directory containing the datafiles for
setchrclass
SEE ALSO
stdio(3S), ascii(5), environ(5).
chrtbl(1M) in the INTERACTIVE UNIX System User's/System
Administrator's Reference Manual.
DIAGNOSTICS
If the argument to any of the character handling macros is
not in the domain of the function, the result is undefined.
If setchrclass does not successfully fill the table, the
table will not change (initially ``ascii'') and -1 is
returned. If everything works, setchrclass returns 0.
WARNING
If a character variable or constant is passed to these func-
tions or macros, undefined results may occur on machines
which sign-extend characters by default.
Rev. C Software Development Set Page 3