aboutsummaryrefslogtreecommitdiff
path: root/man/man3/ctype.3
blob: f00d040e28e7f4692aa118a7d1cab74a2b3c764f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
.TH CTYPE 3
.SH NAME
isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace, ispunct, isprint, isgraph, iscntrl, isascii, toascii, _toupper, _tolower, toupper, tolower \- ASCII character classification
.SH SYNOPSIS
.B #include <u.h>
.br
.B #include <libc.h>
.br
.B #include <ctype.h>
.PP
.if t .2C
.B isalpha(c)
.PP
.B isupper(c)
.PP
.B islower(c)
.PP
.B isdigit(c)
.PP
.B isxdigit(c)
.PP
.B isalnum(c)
.PP
.B isspace(c)
.PP
.B ispunct(c)
.PP
.B isprint(c)
.PP
.B isgraph(c)
.PP
.B iscntrl(c)
.PP
.B isascii(c)
.PP
.B _toupper(c)
.PP
.B _tolower(c)
.PP
.B toupper(c)
.PP
.B tolower(c)
.PP
.B toascii(c)
.if t .1C
.SH DESCRIPTION
These macros classify
.SM ASCII\c
-coded integer values
by table lookup.
Each is a predicate returning nonzero for true,
zero for false.
.I Isascii
is defined on all integer values; the rest
are defined only where
.I isascii
is true and on the single non-\c
.SM ASCII
value
.BR EOF ;
see
.IR fopen (2).
.TP "\w'isalnum  'u"
.I isalpha
.I c
is a letter, a\-z or A\-Z
.TP
.I isupper
.I c
is an upper case letter, A\-Z
.TP
.I islower
.I c
is a lower case letter, a\-z
.TP
.I isdigit
.I c
is a digit, 0\-9
.TP
.I isxdigit
.I c
is a hexadecimal digit, 0\-9 or a\-f or A\-F
.TP
.I isalnum
.I c
is an alphanumeric character, a\-z or A\-Z or 0\-9
.TP
.I isspace
.I c
is a space, horizontal tab, newline, vertical tab, formfeed, or carriage return
(0x20, 0x9, 0xA, 0xB, 0xC, 0xD)
.TP
.I ispunct
.I c
is a punctuation character
(one of
.L
!"#$%&'()*+,-./:;<=>?@[\e]^_`{|}~\fR)
.TP
.I isprint
.I c
is a printing character, 0x20 (space)
through 0x7E (tilde) 
.TP
.I isgraph
.I c
is a visible printing character, 0x21 (exclamation) through 0x7E
(tilde)
.TP
.I iscntrl
.I c
is a delete character, 0x7F,
or ordinary control character, 0x0 through 0x1F
.TP
.I isascii
.I c
is an
.SM ASCII
character, 0x0 through 0x7F
.PP
.I Toascii
is not a classification macro;
it converts its argument to
.SM ASCII
range by
.IR and ing
with 0x7F.
.PP
If
.I c
is an upper case letter,
.I tolower
returns the lower case version of the character;
otherwise it returns the original character.
.I Toupper
is similar, returning the upper case version of a character
or the original character.
.I Tolower
and
.I toupper
are functions;
.I _tolower
and
.I _toupper
are corresponding macros which should only be used when it
is known that the argument is upper case or lower case, respectively.
.SH SOURCE
.TF /sys/src/libc/port/ctype.c
.TP
.B /sys/include/ctype.h
for the macros.
.TP
.B /sys/src/libc/port/ctype.c
for the tables.
.SH "SEE ALSO
.IR isalpharune (2)
.SH BUGS
These macros are
.SM ASCII \c
-centric.