xref: /plan9/sys/man/2/ctype (revision 2bef681aed9a53ac1dc6db418047b00f7a5ce209)
CTYPE 2
NAME
isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, toascii, _toupper, _tolower, toupper, tolower - ASCII character classification
SYNOPSIS
#include <u.h>

#include <libc.h>

#include <ctype.h>

isalpha(c)

isupper(c)

islower(c)

isdigit(c)

isxdigit(c)

isalnum(c)

isspace(c)

ispunct(c)

isprint(c)

isgraph(c)

iscntrl(c)

isascii(c)

_toupper(c)

_tolower(c)

toupper(c)

tolower(c)

toascii(c)

DESCRIPTION
These macros classify ASCII\c -coded integer values by table lookup. Each is a predicate returning nonzero for true, zero for false. Isascii is defined on all integer values; the rest are defined only where isascii is true and on the single non-\c ASCII value EOF ; see fopen (2).

"\w'isalnum 'u" isalpha c is a letter, a-z or A-Z

isupper c is an upper case letter, A-Z

islower c is a lower case letter, a-z

isdigit c is a digit, 0-9

isxdigit c is a hexadecimal digit, 0-9 or a-f or A-F

isalnum c is an alphanumeric character, a-z or A-Z or 0-9

isspace c is a space, horizontal tab, newline, vertical tab, formfeed, or carriage return (0x20, 0x9, 0xA, 0xB, 0xC, 0xD)

ispunct c is a punctuation character (one of .L !"#$%&'()*+,-./:;<=>?@[\e]^_`{|}~)

isprint c is a printing character, 0x20 (space) through 0x7E (tilde)

isgraph c is a visible printing character, 0x21 (exclamation) through 0x7E (tilde)

iscntrl c is a delete character, 0x7F, or ordinary control character, 0x0 through 0x1F

isascii c is an ASCII character, 0x0 through 0x7F

Toascii is not a classification macro; it converts its argument to ASCII range by and ing with 0x7F.

If c is an upper case letter, tolower returns the lower case version of the character; otherwise it returns the original character. Toupper is similar, returning the upper case version of a character or the original character. Tolower and toupper are functions; _tolower and _toupper are corresponding macros which should only be used when it is known that the argument is upper case or lower case, respectively.

SOURCE
.TF /sys/src/libc/port/ctype.c

/sys/include/ctype.h for the macros.

/sys/src/libc/port/ctype.c for the tables.

"SEE ALSO
isalpharune (2)
BUGS
These macros are ASCII\c -centric.