1 '\" te
2 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 .\" Copyright 1989 AT&T. Copyright (c) 1992, X/Open Company Limited All Rights Reserved. Portions Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
4 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
7 .\" This notice shall appear on any product containing this material.
8 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
9 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
10 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
11 .TH CTYPE 3C "Jun 27, 2014"
12 .SH NAME
13 ctype, isalpha, isalnum, isascii, isblank, iscntrl, isdigit, islower,
14 isprint, isspace, isupper, ispunct, isgraph, isxdigit, isalpha_l,
15 isalnum_l, isblank_l, iscntrl_l, isdigit_l, islower_l, isprint_l,
16 isspace_l, isupper_l, ispunct_l, isgraph_l \- character handling
17 .SH SYNOPSIS
18 .LP
19 .nf
20 #include <ctype.h>
21
22 \fBint\fR \fBisalpha\fR(\fBint\fR \fIc\fR);
23 .fi
24 .LP
25 .nf
26 \fBint\fR \fBisalnum\fR(\fBint\fR \fIc\fR);
27 .fi
28 .LP
29 .nf
30 \fBint\fR \fBisascii\fR(\fBint\fR \fIc\fR);
31 .fi
32 .LP
33 .nf
34 \fBint\fR \fBisblank\fR(\fBint\fR \fIc\fR);
35 .fi
36 .LP
37 .nf
38 \fBint\fR \fBiscntrl\fR(\fBint\fR \fIc\fR);
39 .fi
40 .LP
41 .nf
42 \fBint\fR \fBisdigit\fR(\fBint\fR \fIc\fR);
43 .fi
44 .LP
45 .nf
46 \fBint\fR \fBisgraph\fR(\fBint\fR \fIc\fR);
47 .fi
48 .LP
49 .nf
50 \fBint\fR \fBislower\fR(\fBint\fR \fIc\fR);
51 .fi
52 .LP
53 .nf
54 \fBint\fR \fBisprint\fR(\fBint\fR \fIc\fR);
55 .fi
56 .LP
57 .nf
58 \fBint\fR \fBispunct\fR(\fBint\fR \fIc\fR);
59 .fi
60 .LP
61 .nf
62 \fBint\fR \fBisspace\fR(\fBint\fR \fIc\fR);
63 .fi
64 .LP
65 .nf
66 \fBint\fR \fBisupper\fR(\fBint\fR \fIc\fR);
67 .fi
68 .LP
69 .nf
70 \fBint\fR \fBisxdigit\fR(\fBint\fR \fIc\fR);
71 .fi
72 .LP
73 .nf
74 \fBint\fR \fBisalpha_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
75 .fi
76 .LP
77 .nf
78 \fBint\fR \fBisalnum_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
79 .fi
80 .LP
81 .nf
82 \fBint\fR \fBisblank_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
83 .fi
84 .LP
85 .nf
86 \fBint\fR \fBiscntrl_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
87 .fi
88 .LP
89 .nf
90 \fBint\fR \fBisdigit_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
91 .fi
92 .LP
93 .nf
94 \fBint\fR \fBisgraph_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
95 .fi
96 .LP
97 .nf
98 \fBint\fR \fBislower_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
99 .fi
100 .LP
101 .nf
102 \fBint\fR \fBisprint_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
103 .fi
104 .LP
105 .nf
106 \fBint\fR \fBispunct_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
107 .fi
108 .LP
109 .nf
110 \fBint\fR \fBisspace_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
111 .fi
112 .LP
113 .nf
114 \fBint\fR \fBisupper_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR);
115 .fi
116 .SH DESCRIPTION
117 .LP
118 These functions classify character-coded integer values. Each is a
119 predicate returning non-zero for true, \fB0\fR for false. The behavior
120 of these macros, except \fBisascii()\fR, is affected by the current
121 locale (see \fBsetlocale\fR(3C) and \fBuselocale\fR(3C)). To modify
122 the behavior, change the \fBLC_TYPE\fR category in \fBsetlocale()\fR, that is,
123 \fBsetlocale(\fR\fBLC_CTYPE\fR, \fInewlocale\fR). In the "C" locale,
124 or in a locale where character type information is not defined,
125 characters are classified according to the rules of the \fBUS-ASCII\fR
126 7-bit coded character set.
127 .LP
128 The functions \fBisalnum_l()\fR, \fBisalpha_l()\fR, \fBisblank_l()\fR,
129 \fBiscntrl_l\fR, \fBisdigit_l()\fR, \fBislower_l()\fR,
130 \fBisprint_l()\fR, \fBispunct_l()\fR, \fBisspace_l()\fR,
131 \fBisupper_l()\fR, all behave identically to their counterparts without
132 the '\fB_l\fR' prefix, except that instead of acting on the current
133 locale, that perform the test on the locale specified in the argument
134 \fIloc\fR.
135 .LP
136 The \fBisascii()\fR macro is defined on all integer values. The rest are
137 defined only where the argument is an \fBint\fR, the value of which is
138 representable as an \fBunsigned char\fR, or \fBEOF\fR, which is defined by the
139 <\fBstdio.h\fR> header and represents end-of-file.
140 .sp
141 .ne 2
142 .na
143 \fB\fBisalpha()\fR\fR
144 .ad
145 .RS 13n
146 Tests for any character for which \fBisupper()\fR or \fBislower()\fR is true,
147 or any character that is one of the current locale-defined set of characters
148 for which none of \fBiscntrl()\fR, \fBisdigit()\fR, \fBispunct()\fR, or
149 \fBisspace()\fR is true. In "C" locale, \fBisalpha()\fR returns true only for
150 the characters for which \fBisupper()\fR or \fBislower()\fR is true.
151 .RE
152
153 .sp
154 .ne 2
155 .na
156 \fB\fBisalnum()\fR\fR
157 .ad
158 .RS 13n
159 Tests for any character for which \fBisalpha()\fR or \fBisdigit()\fR is true
160 (letter or digit).
161 .RE
162
163 .sp
164 .ne 2
165 .na
166 \fB\fBisascii()\fR\fR
167 .ad
168 .RS 13n
169 Tests for any ASCII character, code between \fB0\fR and \fB0177\fR inclusive.
170 .RE
171
172 .sp
173 .ne 2
174 .na
175 \fB\fBisblank()\fR\fR
176 .ad
177 .RS 13n
178 Tests whether \fIc\fR is a character of class blank in the current locale. This
179 macro/function is not available to applications conforming to standards prior
180 to SUSv3. See \fBstandards\fR(5)
181 .RE
182
183 .sp
184 .ne 2
185 .na
186 \fB\fBiscntrl()\fR\fR
187 .ad
188 .RS 13n
189 Tests for any ``control character'' as defined by the character set.
190 .RE
191
192 .sp
193 .ne 2
194 .na
195 \fB\fBisdigit()\fR\fR
196 .ad
197 .RS 13n
198 Tests for any decimal-digit character.
199 .RE
200
201 .sp
202 .ne 2
203 .na
204 \fB\fBisgraph()\fR\fR
205 .ad
206 .RS 13n
207 Tests for any character for which \fBisalnum()\fR and \fBispunct()\fR are true,
208 or any character in the current locale-defined "graph" class which is neither a
209 space ("\|") nor a character for which \fBiscntrl()\fR is true.
210 .RE
211
212 .sp
213 .ne 2
214 .na
215 \fB\fBislower()\fR\fR
216 .ad
217 .RS 13n
218 Tests for any character that is a lower-case letter or is one of the current
219 locale-defined set of characters for which none of \fBiscntrl()\fR,
220 \fBisdigit()\fR, \fBispunct()\fR, \fBisspace()\fR, or \fBisupper()\fR is true.
221 In the "C" locale, \fBislower()\fR returns true only for the characters defined
222 as lower-case \fBASCII\fR characters.
223 .RE
224
225 .sp
226 .ne 2
227 .na
228 \fB\fBisprint()\fR\fR
229 .ad
230 .RS 13n
231 Tests for any character for which \fBiscntrl()\fR is false, and
232 \fBisalnum()\fR, \fBisgraph()\fR, \fBispunct()\fR, the space character ("\|"),
233 and the characters in the current locale-defined "print" class are true.
234 .RE
235
236 .sp
237 .ne 2
238 .na
239 \fB\fBispunct()\fR\fR
240 .ad
241 .RS 13n
242 Tests for any printing character which is neither a space ("\|") nor a
243 character for which \fBisalnum()\fR or \fBiscntrl()\fR is true.
244 .RE
245
246 .sp
247 .ne 2
248 .na
249 \fB\fBisspace()\fR\fR
250 .ad
251 .RS 13n
252 Tests for any space, tab, carriage-return, newline, vertical-tab or form-feed
253 (standard white-space characters) or for one of the current locale-defined set
254 of characters for which \fBisalnum()\fR is false. In the "C" locale,
255 \fBisspace()\fR returns true only for the standard white-space characters.
256 .RE
257
258 .sp
259 .ne 2
260 .na
261 \fB\fBisupper()\fR\fR
262 .ad
263 .RS 13n
264 Tests for any character that is an upper-case letter or is one of the current
265 locale-defined set of characters for which none of \fBiscntrl()\fR,
266 \fBisdigit()\fR, \fBispunct()\fR, \fBisspace()\fR, or \fBislower()\fR is true.
267 In the "C" locale, \fBisupper()\fR returns true only for the characters defined
268 as upper-case \fBASCII\fR characters.
269 .RE
270
271 .sp
272 .ne 2
273 .na
274 \fB\fBisxdigit()\fR\fR
275 .ad
276 .RS 14n
277 Tests for any hexadecimal-digit character (\fB[0\(mi9]\fR, \fB[A\(miF]\fR, or
278 \fB[a\(mif]\fR or the current locale-defined sets of characters representing
279 the hexadecimal digits \fB10\fR to \fB15\fR inclusive). In the "C" locale, only
280 .sp
281 .in +2
282 .nf
283 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
284 .fi
285 .in -2
286
287 are included.
288 .RE
289
290 .SH RETURN VALUES
291 .LP
292 If the argument to any of the character handling macros is not in the domain of
293 the function, the result is undefined. Otherwise, the macro or function returns
294 non-zero if the classification is \fBTRUE\fR and \fB0\fR if the classification
295 is \fBFALSE\fR.
296 .SH ATTRIBUTES
297 .sp
298 .LP
299 See \fBattributes\fR(5) for descriptions of the following attributes:
300 .TS
301 box;
302 c | c
303 l | l .
304 ATTRIBUTE TYPE ATTRIBUTE VALUE
305 _
306 CSI Enabled
307 _
308 Interface Stability Standard
309 _
310 MT-Level MT-Safe
311 .TE
312
313 .SH SEE ALSO
314 .LP
315 \fBnewlocale\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C),
316 \fBstdio\fR(3C), \fBascii\fR(5), \fBenviron\fR(5),
317 \fBstandards\fR(5)