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