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 "Aug 20, 2019" 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 .nf 57 #include <ctype.h> 58 59 \fBint\fR \fBisalpha\fR(\fBint\fR \fIc\fR); 60 .fi 61 .LP 62 .nf 63 \fBint\fR \fBisalnum\fR(\fBint\fR \fIc\fR); 64 .fi 65 .LP 66 .nf 67 \fBint\fR \fBisascii\fR(\fBint\fR \fIc\fR); 68 .fi 69 .LP 70 .nf 71 \fBint\fR \fBisblank\fR(\fBint\fR \fIc\fR); 72 .fi 73 .LP 74 .nf 75 \fBint\fR \fBiscntrl\fR(\fBint\fR \fIc\fR); 76 .fi 77 .LP 78 .nf 79 \fBint\fR \fBisdigit\fR(\fBint\fR \fIc\fR); 80 .fi 81 .LP 82 .nf 83 \fBint\fR \fBisgraph\fR(\fBint\fR \fIc\fR); 84 .fi 85 .LP 86 .nf 87 \fBint\fR \fBislower\fR(\fBint\fR \fIc\fR); 88 .fi 89 .LP 90 .nf 91 \fBint\fR \fBisprint\fR(\fBint\fR \fIc\fR); 92 .fi 93 .LP 94 .nf 95 \fBint\fR \fBispunct\fR(\fBint\fR \fIc\fR); 96 .fi 97 .LP 98 .nf 99 \fBint\fR \fBisspace\fR(\fBint\fR \fIc\fR); 100 .fi 101 .LP 102 .nf 103 \fBint\fR \fBisupper\fR(\fBint\fR \fIc\fR); 104 .fi 105 .LP 106 .nf 107 \fBint\fR \fBisxdigit\fR(\fBint\fR \fIc\fR); 108 .fi 109 .LP 110 .nf 111 \fBint\fR \fBisalpha_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 112 .fi 113 .LP 114 .nf 115 \fBint\fR \fBisalnum_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 116 .fi 117 .LP 118 .nf 119 \fBint\fR \fBisblank_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 120 .fi 121 .LP 122 .nf 123 \fBint\fR \fBiscntrl_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 124 .fi 125 .LP 126 .nf 127 \fBint\fR \fBisdigit_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 128 .fi 129 .LP 130 .nf 131 \fBint\fR \fBisgraph_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 132 .fi 133 .LP 134 .nf 135 \fBint\fR \fBislower_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 136 .fi 137 .LP 138 .nf 139 \fBint\fR \fBisprint_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 140 .fi 141 .LP 142 .nf 143 \fBint\fR \fBispunct_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 144 .fi 145 .LP 146 .nf 147 \fBint\fR \fBisspace_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 148 .fi 149 .LP 150 .nf 151 \fBint\fR \fBisupper_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 152 .fi 153 .LP 154 .nf 155 \fBint\fR \fBisxdigit_l\fR(\fBint\fR \fIc\fR, \fBlocale_t\fR \fIloc\fR); 156 .fi 157 .SH DESCRIPTION 158 These functions classify character-coded integer values. Each is a 159 predicate returning non-zero for true, \fB0\fR for false. The behavior 160 of these macros, except \fBisascii()\fR, is affected by the current 161 locale (see \fBsetlocale\fR(3C) and \fBuselocale\fR(3C)). To modify 162 the behavior, change the \fBLC_TYPE\fR category in \fBsetlocale()\fR, that is, 163 \fBsetlocale(\fR\fBLC_CTYPE\fR, \fInewlocale\fR). In the "C" locale, 164 or in a locale where character type information is not defined, 165 characters are classified according to the rules of the \fBUS-ASCII\fR 166 7-bit coded character set. 167 .LP 168 The functions \fBisalnum_l()\fR, \fBisalpha_l()\fR, \fBisblank_l()\fR, 169 \fBiscntrl_l\fR, \fBisdigit_l()\fR, \fBisgraph_l()\fR, 170 \fBislower_l()\fR, \fBisprint_l()\fR, \fBispunct_l()\fR, 171 \fBisspace_l()\fR, \fBisupper_l()\fR, and \fBisxdigit_l()\fR all behave 172 identically to their counterparts without the '\fB_l\fR' prefix, except 173 that instead of acting on the current locale, they perform the test on 174 the locale specified in the argument \fIloc\fR. 175 .LP 176 The \fBisascii()\fR macro is defined on all integer values. The rest are 177 defined only where the argument is an \fBint\fR, the value of which is 178 representable as an \fBunsigned char\fR, or \fBEOF\fR, which is defined by the 179 <\fBstdio.h\fR> header and represents end-of-file. 180 .sp 181 .ne 2 182 .na 183 \fBisalpha()\fR 184 .ad 185 .RS 13n 186 Tests for any character for which \fBisupper()\fR or \fBislower()\fR is true, 187 or any character that is one of the current locale-defined set of characters 188 for which none of \fBiscntrl()\fR, \fBisdigit()\fR, \fBispunct()\fR, or 189 \fBisspace()\fR is true. In "C" locale, \fBisalpha()\fR returns true only for 190 the characters for which \fBisupper()\fR or \fBislower()\fR is true. 191 .RE 192 193 .sp 194 .ne 2 195 .na 196 \fBisalnum()\fR 197 .ad 198 .RS 13n 199 Tests for any character for which \fBisalpha()\fR or \fBisdigit()\fR is true 200 (letter or digit). 201 .RE 202 203 .sp 204 .ne 2 205 .na 206 \fBisascii()\fR 207 .ad 208 .RS 13n 209 Tests for any ASCII character, code between \fB0\fR and \fB0177\fR inclusive. 210 .RE 211 212 .sp 213 .ne 2 214 .na 215 \fBisblank()\fR 216 .ad 217 .RS 13n 218 Tests whether \fIc\fR is a character of class blank in the current locale. This 219 macro/function is not available to applications conforming to standards prior 220 to SUSv3. See \fBstandards\fR(5) 221 .RE 222 223 .sp 224 .ne 2 225 .na 226 \fBiscntrl()\fR 227 .ad 228 .RS 13n 229 Tests for any ``control character'' as defined by the character set. 230 .RE 231 232 .sp 233 .ne 2 234 .na 235 \fBisdigit()\fR 236 .ad 237 .RS 13n 238 Tests for any decimal-digit character. 239 .RE 240 241 .sp 242 .ne 2 243 .na 244 \fBisgraph()\fR 245 .ad 246 .RS 13n 247 Tests for any character for which \fBisalnum()\fR and \fBispunct()\fR are true, 248 or any character in the current locale-defined "graph" class which is neither a 249 space ("\|") nor a character for which \fBiscntrl()\fR is true. 250 .RE 251 252 .sp 253 .ne 2 254 .na 255 \fBislower()\fR 256 .ad 257 .RS 13n 258 Tests for any character that is a lower-case letter or is one of the current 259 locale-defined set of characters for which none of \fBiscntrl()\fR, 260 \fBisdigit()\fR, \fBispunct()\fR, \fBisspace()\fR, or \fBisupper()\fR is true. 261 In the "C" locale, \fBislower()\fR returns true only for the characters defined 262 as lower-case \fBASCII\fR characters. 263 .RE 264 265 .sp 266 .ne 2 267 .na 268 \fBisprint()\fR 269 .ad 270 .RS 13n 271 Tests for any character for which \fBiscntrl()\fR is false, and 272 \fBisalnum()\fR, \fBisgraph()\fR, \fBispunct()\fR, the space character ("\|"), 273 and the characters in the current locale-defined "print" class are true. 274 .RE 275 276 .sp 277 .ne 2 278 .na 279 \fBispunct()\fR 280 .ad 281 .RS 13n 282 Tests for any printing character which is neither a space ("\|") nor a 283 character for which \fBisalnum()\fR or \fBiscntrl()\fR is true. 284 .RE 285 286 .sp 287 .ne 2 288 .na 289 \fBisspace()\fR 290 .ad 291 .RS 13n 292 Tests for any space, tab, carriage-return, newline, vertical-tab or form-feed 293 (standard white-space characters) or for one of the current locale-defined set 294 of characters for which \fBisalnum()\fR is false. In the "C" locale, 295 \fBisspace()\fR returns true only for the standard white-space characters. 296 .RE 297 298 .sp 299 .ne 2 300 .na 301 \fBisupper()\fR 302 .ad 303 .RS 13n 304 Tests for any character that is an upper-case letter or is one of the current 305 locale-defined set of characters for which none of \fBiscntrl()\fR, 306 \fBisdigit()\fR, \fBispunct()\fR, \fBisspace()\fR, or \fBislower()\fR is true. 307 In the "C" locale, \fBisupper()\fR returns true only for the characters defined 308 as upper-case \fBASCII\fR characters. 309 .RE 310 311 .sp 312 .ne 2 313 .na 314 \fBisxdigit()\fR 315 .ad 316 .RS 14n 317 Tests for any hexadecimal-digit character (\fB[0\(mi9]\fR, \fB[A\(miF]\fR, or 318 \fB[a\(mif]\fR or the current locale-defined sets of characters representing 319 the hexadecimal digits \fB10\fR to \fB15\fR inclusive). In the "C" locale, only 320 .sp 321 .in +2 322 .nf 323 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f 324 .fi 325 .in -2 326 327 are included. 328 .RE 329 330 .SH RETURN VALUES 331 If the argument to any of the character handling macros is not in the domain of 332 the function, the result is undefined. Otherwise, the macro or function returns 333 non-zero if the classification is \fBTRUE\fR and \fB0\fR if the classification 334 is \fBFALSE\fR. 335 .SH ATTRIBUTES 336 See \fBattributes\fR(5) for descriptions of the following attributes: 337 .TS 338 box; 339 c | c 340 l | l . 341 ATTRIBUTE TYPE ATTRIBUTE VALUE 342 _ 343 CSI Enabled 344 _ 345 Interface Stability Standard 346 _ 347 MT-Level MT-Safe 348 .TE 349 350 .SH SEE ALSO 351 \fBnewlocale\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C), 352 \fBstdio\fR(3C), \fBascii\fR(5), \fBenviron\fR(5), 353 \fBstandards\fR(5)