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