1 '\" te 2 .\" Copyright 2013 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 "Sep 18, 2013" 12 .SH NAME 13 ctype, isalpha, isalnum, isascii, isblank, iscntrl, isdigit, islower, isprint, 14 isspace, isupper, ispunct, isgraph, isxdigit \- character handling 15 .SH SYNOPSIS 16 .LP 17 .nf 18 #include <ctype.h> 19 20 \fBint\fR \fBisalpha\fR(\fBint\fR \fIc\fR); 21 .fi 22 23 .LP 24 .nf 25 \fBint\fR \fBisalnum\fR(\fBint\fR \fIc\fR); 26 .fi 27 28 .LP 29 .nf 30 \fBint\fR \fBisascii\fR(\fBint\fR \fIc\fR); 31 .fi 32 33 .LP 34 .nf 35 \fBint\fR \fBisblank\fR(\fBint\fR \fIc\fR); 36 .fi 37 38 .LP 39 .nf 40 \fBint\fR \fBiscntrl\fR(\fBint\fR \fIc\fR); 41 .fi 42 43 .LP 44 .nf 45 \fBint\fR \fBisdigit\fR(\fBint\fR \fIc\fR); 46 .fi 47 48 .LP 49 .nf 50 \fBint\fR \fBisgraph\fR(\fBint\fR \fIc\fR); 51 .fi 52 53 .LP 54 .nf 55 \fBint\fR \fBislower\fR(\fBint\fR \fIc\fR); 56 .fi 57 58 .LP 59 .nf 60 \fBint\fR \fBisprint\fR(\fBint\fR \fIc\fR); 61 .fi 62 63 .LP 64 .nf 65 \fBint\fR \fBispunct\fR(\fBint\fR \fIc\fR); 66 .fi 67 68 .LP 69 .nf 70 \fBint\fR \fBisspace\fR(\fBint\fR \fIc\fR); 71 .fi 72 73 .LP 74 .nf 75 \fBint\fR \fBisupper\fR(\fBint\fR \fIc\fR); 76 .fi 77 78 .LP 79 .nf 80 \fBint\fR \fBisxdigit\fR(\fBint\fR \fIc\fR); 81 .fi 82 83 .SH DESCRIPTION 84 .sp 85 .LP 86 These macros classify character-coded integer values. Each is a predicate 87 returning non-zero for true, \fB0\fR for false. The behavior of these macros, 88 except \fBisascii()\fR, is affected by the current locale (see 89 \fBsetlocale\fR(3C)). To modify the behavior, change the \fBLC_TYPE\fR category 90 in \fBsetlocale()\fR, that is, \fBsetlocale(\fR\fBLC_CTYPE\fR, 91 \fInewlocale\fR). In the "C" locale, or in a locale where character type 92 information is not defined, characters are classified according to the rules of 93 the \fBUS-ASCII\fR 7-bit coded character set. 94 .sp 95 .LP 96 The \fBisascii()\fR macro is defined on all integer values. The rest are 97 defined only where the argument is an \fBint\fR, the value of which is 98 representable as an \fBunsigned char\fR, or \fBEOF\fR, which is defined by the 99 <\fBstdio.h\fR> header and represents end-of-file. 100 .sp 101 .LP 102 Functions exist for all the macros defined below. To get the function form, the 103 macro name must be undefined (for example, \fB#undef isdigit\fR). 104 105 .sp 106 .ne 2 107 .na 108 \fB\fBisalpha()\fR\fR 109 .ad 110 .RS 13n 111 Tests for any character for which \fBisupper()\fR or \fBislower()\fR is true, 112 or any character that is one of the current locale-defined set of characters 113 for which none of \fBiscntrl()\fR, \fBisdigit()\fR, \fBispunct()\fR, or 114 \fBisspace()\fR is true. In "C" locale, \fBisalpha()\fR returns true only for 115 the characters for which \fBisupper()\fR or \fBislower()\fR is true. 116 .RE 117 118 .sp 119 .ne 2 120 .na 121 \fB\fBisalnum()\fR\fR 122 .ad 123 .RS 13n 124 Tests for any character for which \fBisalpha()\fR or \fBisdigit()\fR is true 125 (letter or digit). 126 .RE 127 128 .sp 129 .ne 2 130 .na 131 \fB\fBisascii()\fR\fR 132 .ad 133 .RS 13n 134 Tests for any ASCII character, code between \fB0\fR and \fB0177\fR inclusive. 135 .RE 136 137 .sp 138 .ne 2 139 .na 140 \fB\fBisblank()\fR\fR 141 .ad 142 .RS 13n 143 Tests whether \fIc\fR is a character of class blank in the current locale. This 144 macro/function is not available to applications conforming to standards prior 145 to SUSv3. See \fBstandards\fR(5) 146 .RE 147 148 .sp 149 .ne 2 150 .na 151 \fB\fBiscntrl()\fR\fR 152 .ad 153 .RS 13n 154 Tests for any ``control character'' as defined by the character set. 155 .RE 156 157 .sp 158 .ne 2 159 .na 160 \fB\fBisdigit()\fR\fR 161 .ad 162 .RS 13n 163 Tests for any decimal-digit character. 164 .RE 165 166 .sp 167 .ne 2 168 .na 169 \fB\fBisgraph()\fR\fR 170 .ad 171 .RS 13n 172 Tests for any character for which \fBisalnum()\fR and \fBispunct()\fR are true, 173 or any character in the current locale-defined "graph" class which is neither a 174 space ("\|") nor a character for which \fBiscntrl()\fR is true. 175 .RE 176 177 .sp 178 .ne 2 179 .na 180 \fB\fBislower()\fR\fR 181 .ad 182 .RS 13n 183 Tests for any character that is a lower-case letter or is one of the current 184 locale-defined set of characters for which none of \fBiscntrl()\fR, 185 \fBisdigit()\fR, \fBispunct()\fR, \fBisspace()\fR, or \fBisupper()\fR is true. 186 In the "C" locale, \fBislower()\fR returns true only for the characters defined 187 as lower-case \fBASCII\fR characters. 188 .RE 189 190 .sp 191 .ne 2 192 .na 193 \fB\fBisprint()\fR\fR 194 .ad 195 .RS 13n 196 Tests for any character for which \fBiscntrl()\fR is false, and 197 \fBisalnum()\fR, \fBisgraph()\fR, \fBispunct()\fR, the space character ("\|"), 198 and the characters in the current locale-defined "print" class are true. 199 .RE 200 201 .sp 202 .ne 2 203 .na 204 \fB\fBispunct()\fR\fR 205 .ad 206 .RS 13n 207 Tests for any printing character which is neither a space ("\|") nor a 208 character for which \fBisalnum()\fR or \fBiscntrl()\fR is true. 209 .RE 210 211 .sp 212 .ne 2 213 .na 214 \fB\fBisspace()\fR\fR 215 .ad 216 .RS 13n 217 Tests for any space, tab, carriage-return, newline, vertical-tab or form-feed 218 (standard white-space characters) or for one of the current locale-defined set 219 of characters for which \fBisalnum()\fR is false. In the "C" locale, 220 \fBisspace()\fR returns true only for the standard white-space characters. 221 .RE 222 223 .sp 224 .ne 2 225 .na 226 \fB\fBisupper()\fR\fR 227 .ad 228 .RS 13n 229 Tests for any character that is an upper-case letter or is one of the current 230 locale-defined set of characters for which none of \fBiscntrl()\fR, 231 \fBisdigit()\fR, \fBispunct()\fR, \fBisspace()\fR, or \fBislower()\fR is true. 232 In the "C" locale, \fBisupper()\fR returns true only for the characters defined 233 as upper-case \fBASCII\fR characters. 234 .RE 235 236 .sp 237 .ne 2 238 .na 239 \fB\fBisxdigit()\fR\fR 240 .ad 241 .RS 14n 242 Tests for any hexadecimal-digit character (\fB[0\(mi9]\fR, \fB[A\(miF]\fR, or 243 \fB[a\(mif]\fR or the current locale-defined sets of characters representing 244 the hexadecimal digits \fB10\fR to \fB15\fR inclusive). In the "C" locale, only 245 .sp 246 .in +2 247 .nf 248 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f 249 .fi 250 .in -2 251 252 are included. 253 .RE 254 255 .SH RETURN VALUES 256 .sp 257 .LP 258 If the argument to any of the character handling macros is not in the domain of 259 the function, the result is undefined. Otherwise, the macro or function returns 260 non-zero if the classification is \fBTRUE\fR and \fB0\fR if the classification 261 is \fBFALSE\fR. 262 .SH USAGE 263 .sp 264 .LP 265 These macros or functions can be used safely in multithreaded applications, as 266 long as \fBsetlocale\fR(3C) is not being called to change the locale. 267 .SH ATTRIBUTES 268 .sp 269 .LP 270 See \fBattributes\fR(5) for descriptions of the following attributes: 271 .sp 272 273 .sp 274 .TS 275 box; 276 l l 277 l l . 278 ATTRIBUTE TYPE ATTRIBUTE VALUE 279 CSI Enabled 280 Interface Stability Standard 281 MT-Level MT-Safe with exceptions 282 .TE 283 284 .SH SEE ALSO 285 .sp 286 .LP 287 \fBsetlocale\fR(3C), \fBstdio\fR(3C), \fBascii\fR(5), \fBenviron\fR(5), 288 \fBstandards\fR(5)