1 CTYPE(3C) Standard C Library Functions CTYPE(3C) 2 3 4 5 NAME 6 ctype, isalpha, isalnum, isascii, isblank, iscntrl, isdigit, islower, 7 isprint, isspace, isupper, ispunct, isgraph, isxdigit, isalpha_l, 8 isalnum_l, isblank_l, iscntrl_l, isdigit_l, islower_l, isprint_l, 9 isspace_l, isupper_l, ispunct_l, isgraph_l, isxdigit_l - character 10 handling 11 12 SYNOPSIS 13 #include <ctype.h> 14 15 int isalpha(int c); 16 17 int isalnum(int c); 18 19 int isascii(int c); 20 21 int isblank(int c); 22 23 int iscntrl(int c); 24 25 int isdigit(int c); 26 27 int isgraph(int c); 28 29 int islower(int c); 30 31 int isprint(int c); 32 33 int ispunct(int c); 34 35 int isspace(int c); 36 37 int isupper(int c); 38 39 int isxdigit(int c); 40 41 int isalpha_l(int c, locale_t loc); 42 43 int isalnum_l(int c, locale_t loc); 44 45 int isblank_l(int c, locale_t loc); 46 47 int iscntrl_l(int c, locale_t loc); 48 49 int isdigit_l(int c, locale_t loc); 50 51 int isgraph_l(int c, locale_t loc); 52 53 int islower_l(int c, locale_t loc); 54 55 int isprint_l(int c, locale_t loc); 56 57 int ispunct_l(int c, locale_t loc); 58 59 int isspace_l(int c, locale_t loc); 60 61 int isupper_l(int c, locale_t loc); 62 63 int isxdigit_l(int c, locale_t loc); 64 65 DESCRIPTION 66 These functions classify character-coded integer values. Each is a 67 predicate returning non-zero for true, 0 for false. The behavior of 68 these macros, except isascii(), is affected by the current locale (see 69 setlocale(3C) and uselocale(3C)). To modify the behavior, change the 70 LC_TYPE category in setlocale(), that is, setlocale(LC_CTYPE, 71 newlocale). In the "C" locale, or in a locale where character type 72 information is not defined, characters are classified according to the 73 rules of the US-ASCII 7-bit coded character set. 74 75 The functions isalnum_l(), isalpha_l(), isblank_l(), iscntrl_l, 76 isdigit_l(), isgraph_l(), islower_l(), isprint_l(), ispunct_l(), 77 isspace_l(), isupper_l(), and isxdigit_l() all behave identically to 78 their counterparts without the '_l' prefix, except that instead of 79 acting on the current locale, they perform the test on the locale 80 specified in the argument loc. 81 82 The isascii() macro is defined on all integer values. The rest are 83 defined only where the argument is an int, the value of which is 84 representable as an unsigned char, or EOF, which is defined by the 85 <stdio.h> header and represents end-of-file. 86 87 isalpha() 88 Tests for any character for which isupper() or islower() 89 is true, or any character that is one of the current 90 locale-defined set of characters for which none of 91 iscntrl(), isdigit(), ispunct(), or isspace() is true. In 92 "C" locale, isalpha() returns true only for the characters 93 for which isupper() or islower() is true. 94 95 96 isalnum() 97 Tests for any character for which isalpha() or isdigit() 98 is true (letter or digit). 99 100 101 isascii() 102 Tests for any ASCII character, code between 0 and 0177 103 inclusive. 104 105 106 isblank() 107 Tests whether c is a character of class blank in the 108 current locale. This macro/function is not available to 109 applications conforming to standards prior to SUSv3. See 110 standards(5) 111 112 113 iscntrl() 114 Tests for any ``control character'' as defined by the 115 character set. 116 117 118 isdigit() 119 Tests for any decimal-digit character. 120 121 122 isgraph() 123 Tests for any character for which isalnum() and ispunct() 124 are true, or any character in the current locale-defined 125 "graph" class which is neither a space ("") nor a 126 character for which iscntrl() is true. 127 128 129 islower() 130 Tests for any character that is a lower-case letter or is 131 one of the current locale-defined set of characters for 132 which none of iscntrl(), isdigit(), ispunct(), isspace(), 133 or isupper() is true. In the "C" locale, islower() 134 returns true only for the characters defined as lower-case 135 ASCII characters. 136 137 138 isprint() 139 Tests for any character for which iscntrl() is false, and 140 isalnum(), isgraph(), ispunct(), the space character (""), 141 and the characters in the current locale-defined "print" 142 class are true. 143 144 145 ispunct() 146 Tests for any printing character which is neither a space 147 ("") nor a character for which isalnum() or iscntrl() is 148 true. 149 150 151 isspace() 152 Tests for any space, tab, carriage-return, newline, 153 vertical-tab or form-feed (standard white-space 154 characters) or for one of the current locale-defined set 155 of characters for which isalnum() is false. In the "C" 156 locale, isspace() returns true only for the standard 157 white-space characters. 158 159 160 isupper() 161 Tests for any character that is an upper-case letter or is 162 one of the current locale-defined set of characters for 163 which none of iscntrl(), isdigit(), ispunct(), isspace(), 164 or islower() is true. In the "C" locale, isupper() 165 returns true only for the characters defined as upper-case 166 ASCII characters. 167 168 169 isxdigit() 170 Tests for any hexadecimal-digit character ([0-9], [A-F], 171 or [a-f] or the current locale-defined sets of characters 172 representing the hexadecimal digits 10 to 15 inclusive). 173 In the "C" locale, only 174 175 0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f 176 177 are included. 178 179 180 RETURN VALUES 181 If the argument to any of the character handling macros is not in the 182 domain of the function, the result is undefined. Otherwise, the macro 183 or function returns non-zero if the classification is TRUE and 0 if the 184 classification is FALSE. 185 186 ATTRIBUTES 187 See attributes(5) for descriptions of the following attributes: 188 189 +--------------------+-----------------+ 190 | ATTRIBUTE TYPE | ATTRIBUTE VALUE | 191 +--------------------+-----------------+ 192 |CSI | Enabled | 193 +--------------------+-----------------+ 194 |Interface Stability | Standard | 195 +--------------------+-----------------+ 196 |MT-Level | MT-Safe | 197 +--------------------+-----------------+ 198 199 SEE ALSO 200 newlocale(3C), setlocale(3C), uselocale(3C), stdio(3C), ascii(5), 201 environ(5), standards(5) 202 203 204 205 August 20, 2019 CTYPE(3C)