CTYPE(3V)

NAME
ctype, conv, isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, iscntrl, isascii, isgraph, toupper, tolower, toascii - character classification and conversion macros and functions

SYNOPSIS
#include <ctype.h>

isalpha(c)

...

DESCRIPTION

  Character Classification Macros

These macros classify character-coded integer values according to the rules of the coded character set defined by the character type information in the program's locale (category LC_CTYPE). On program startup the LC_CTYPE category of locale is equivalent to the "C" locale.

In the "C" locale, or in a locale where the character type information is not defined, characters are classified according to the rules of the US-ASCII 7-bit coded character set. The control characters are those below 040 (and the single byte 0177) (DEL). See ascii(7).

In all cases that argument is an int, the value of which must be representable as an unsigned char or must equal the value of the macro EOF. If the argument has any other value, the behavior is undefined.

Each is a predicate returning nonzero for true, zero for false. isascii() is defined on all integer values.

isalpha(c)
    c is a letter.

isupper(c)
    c is an upper case letter.

islower(c)
    c is a lower case letter.

isdigit(c)
    c is a digit [0-9].

isxdigit(c)
    c is a hexadecimal digit [0-9], [A-F], or [a-f].

isalnum(c)
    c is an alphanumeric character, that is, c is a letter or a digit.

isspace(c)
    c is a SPACE, TAB, RETURN, NEWLINE, FORMFEED, or vertical tab character.

ispunct(c)
    c is a punctuation character (neither control nor alphanumeric).

isprint(c)
    c is a printing character.

iscntrl(c)
    c is a delete character or ordinary control character.

isascii(c)
    c is an ASCII character, code less than 0200.

isgraph(c)
    c is a visible graphic character.

  Character Conversion Macros

toascii(c)
    Masks c with the correct value so that c is guaranteed to be an ASCII character in the range 0 through 0x7f. Will not perform mapping from a non-ASCII coded character set into ASCII.

  Character Conversion Functions

These functions perform simple conversions on single characters. They replace the previous macro definitions which did not extend to support variant settings of the LC_CTYPE locale category.

toupper(c)
    Converts c to its upper-case equivalent. This function works correctly for all coded character sets and all characters within such sets selected by a valid setting of the LC_CTYPE locale category.

tolower(c)
    Converts c to its lower-case equivalent. This function works correctly for all coded character sets and all characters within such sets selected by a valid setting of the LC_CTYPE locale category.

If the argument to any of these macros is not in the domain of the function, the result is undefined.

SYSTEM V DESCRIPTION

  Character Conversion Macros

The macros _toupper() and _tolower() are faster than the equivalent functions (toupper() and tolower()) but only work properly on a restricted range of characters, and will not work on a LC_CTYPE category other than the default "C" (ASCII).

These macros perform simple conversions on single characters.

_toupper(c)
    converts c to its upper-case equivalent. Note: This only works where c is known to be a lower-case character to start with (presumably checked using islower()).

_tolower(c)
    converts c to its lower-case equivalent. Note: This only works where c is known to be a upper-case character to start with (presumably checked using isupper()).

SEE ALSO
setlocale(3V), ascii(7), iso_8859_1(7)