CTYPE(S) UNIX System V CTYPE(S)
Name
ctype - character handling routines
Syntax
#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(S))
(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.
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
``printing 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
character 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
character 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,
otherwise undefined.
_toupper returns the uppercase representation of a
character for which islower is true,
otherwise 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
character set. These datafiles are searched for in the
special directory /lib/chrclass.
If chrclass is (char *)0, the value of the environment
variable CHRCLASS is used. If CHRCLASS is not set or is
undefined, the table retains its current value, which at
initialization time is ascii.
Files
/lib/chrclass - directory containing the datafiles for
setchrclass
See Also
chrtbl(M), stdio(S), ascii(M), environ(M)
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
functions or macros, undefined results may occur on machines
which sign-extend characters by default.
Standards Conformance
isalnum, isalpha, iscntrl, isdigit, isgraph, islower,
isprint, ispunct, isspace, isupper, isxdigit, tolower and
toupper are conformant with:
AT&T SVID Issue 2, Select Code 307-127;
The X/Open Portability Guide II of January 1987;
ANSI X3.159-198X C Language Draft Standard, May 13,
1988;
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support;
and NIST FIPS 151-1.
_tolower and _toupper are conformant with:
AT&T SVID Issue 2, Select Code 307-127;
and The X/Open Portability Guide II of January 1987.
(printed 6/20/89)