1isalpha(3) Library Functions Manual isalpha(3)
2
3
4
6 isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower,
7 isprint, ispunct, isspace, isupper, isxdigit, isalnum_l, isalpha_l,
8 isascii_l, isblank_l, iscntrl_l, isdigit_l, isgraph_l, islower_l, is‐
9 print_l, ispunct_l, isspace_l, isupper_l, isxdigit_l - character clas‐
10 sification functions
11
13 Standard C library (libc, -lc)
14
16 #include <ctype.h>
17
18 int isalnum(int c);
19 int isalpha(int c);
20 int iscntrl(int c);
21 int isdigit(int c);
22 int isgraph(int c);
23 int islower(int c);
24 int isprint(int c);
25 int ispunct(int c);
26 int isspace(int c);
27 int isupper(int c);
28 int isxdigit(int c);
29
30 int isascii(int c);
31 int isblank(int c);
32
33 int isalnum_l(int c, locale_t locale);
34 int isalpha_l(int c, locale_t locale);
35 int isblank_l(int c, locale_t locale);
36 int iscntrl_l(int c, locale_t locale);
37 int isdigit_l(int c, locale_t locale);
38 int isgraph_l(int c, locale_t locale);
39 int islower_l(int c, locale_t locale);
40 int isprint_l(int c, locale_t locale);
41 int ispunct_l(int c, locale_t locale);
42 int isspace_l(int c, locale_t locale);
43 int isupper_l(int c, locale_t locale);
44 int isxdigit_l(int c, locale_t locale);
45
46 int isascii_l(int c, locale_t locale);
47
48 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
49
50 isascii():
51 _XOPEN_SOURCE
52 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
53 || /* glibc <= 2.19: */ _SVID_SOURCE
54
55 isblank():
56 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
57
58 isalnum_l(), isalpha_l(), isblank_l(), iscntrl_l(), isdigit_l(),
59 isgraph_l(), islower_l(), isprint_l(), ispunct_l(), isspace_l(),
60 isupper_l(), isxdigit_l():
61 Since glibc 2.10:
62 _XOPEN_SOURCE >= 700
63 Before glibc 2.10:
64 _GNU_SOURCE
65
66 isascii_l():
67 Since glibc 2.10:
68 _XOPEN_SOURCE >= 700 && (_SVID_SOURCE || _BSD_SOURCE)
69 Before glibc 2.10:
70 _GNU_SOURCE
71
73 These functions check whether c, which must have the value of an un‐
74 signed char or EOF, falls into a certain character class according to
75 the specified locale. The functions without the "_l" suffix perform
76 the check based on the current locale.
77
78 The functions with the "_l" suffix perform the check based on the lo‐
79 cale specified by the locale object locale. The behavior of these
80 functions is undefined if locale is the special locale object LC_GLOB‐
81 AL_LOCALE (see duplocale(3)) or is not a valid locale object handle.
82
83 The list below explains the operation of the functions without the "_l"
84 suffix; the functions with the "_l" suffix differ only in using the lo‐
85 cale object locale instead of the current locale.
86
87 isalnum()
88 checks for an alphanumeric character; it is equivalent to (isal‐
89 pha(c) || isdigit(c)).
90
91 isalpha()
92 checks for an alphabetic character; in the standard "C" locale,
93 it is equivalent to (isupper(c) || islower(c)). In some lo‐
94 cales, there may be additional characters for which isalpha() is
95 true—letters which are neither uppercase nor lowercase.
96
97 isascii()
98 checks whether c is a 7-bit unsigned char value that fits into
99 the ASCII character set.
100
101 isblank()
102 checks for a blank character; that is, a space or a tab.
103
104 iscntrl()
105 checks for a control character.
106
107 isdigit()
108 checks for a digit (0 through 9).
109
110 isgraph()
111 checks for any printable character except space.
112
113 islower()
114 checks for a lowercase character.
115
116 isprint()
117 checks for any printable character including space.
118
119 ispunct()
120 checks for any printable character which is not a space or an
121 alphanumeric character.
122
123 isspace()
124 checks for white-space characters. In the "C" and "POSIX" lo‐
125 cales, these are: space, form-feed ('\f'), newline ('\n'), car‐
126 riage return ('\r'), horizontal tab ('\t'), and vertical tab
127 ('\v').
128
129 isupper()
130 checks for an uppercase letter.
131
132 isxdigit()
133 checks for hexadecimal digits, that is, one of
134 0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F.
135
137 The values returned are nonzero if the character c falls into the test‐
138 ed class, and zero if not.
139
141 For an explanation of the terms used in this section, see at‐
142 tributes(7).
143
144 ┌────────────────────────────────────────────┬───────────────┬─────────┐
145 │Interface │ Attribute │ Value │
146 ├────────────────────────────────────────────┼───────────────┼─────────┤
147 │isalnum(), isalpha(), isascii(), isblank(), │ Thread safety │ MT-Safe │
148 │iscntrl(), isdigit(), isgraph(), islower(), │ │ │
149 │isprint(), ispunct(), isspace(), isupper(), │ │ │
150 │isxdigit() │ │ │
151 └────────────────────────────────────────────┴───────────────┴─────────┘
152
154 isalnum()
155 isalpha()
156 iscntrl()
157 isdigit()
158 isgraph()
159 islower()
160 isprint()
161 ispunct()
162 isspace()
163 isupper()
164 isxdigit()
165 isblank()
166 C11, POSIX.1-2008.
167
168 isascii()
169 isalnum_l()
170 isalpha_l()
171 isblank_l()
172 iscntrl_l()
173 isdigit_l()
174 isgraph_l()
175 islower_l()
176 isprint_l()
177 ispunct_l()
178 isspace_l()
179 isupper_l()
180 isxdigit_l()
181 POSIX.1-2008.
182
183 isascii_l()
184 GNU.
185
187 isalnum()
188 isalpha()
189 iscntrl()
190 isdigit()
191 isgraph()
192 islower()
193 isprint()
194 ispunct()
195 isspace()
196 isupper()
197 isxdigit()
198 C89, POSIX.1-2001.
199
200 isblank()
201 C99, POSIX.1-2001.
202
203 isascii()
204 POSIX.1-2001 (XSI).
205
206 POSIX.1-2008 marks it as obsolete, noting that it cannot be used
207 portably in a localized application.
208
209 isalnum_l()
210 isalpha_l()
211 isblank_l()
212 iscntrl_l()
213 isdigit_l()
214 isgraph_l()
215 islower_l()
216 isprint_l()
217 ispunct_l()
218 isspace_l()
219 isupper_l()
220 isxdigit_l()
221 glibc 2.3. POSIX.1-2008.
222
223 isascii_l()
224 glibc 2.3.
225
227 The standards require that the argument c for these functions is either
228 EOF or a value that is representable in the type unsigned char. If the
229 argument c is of type char, it must be cast to unsigned char, as in the
230 following example:
231
232 char c;
233 ...
234 res = toupper((unsigned char) c);
235
236 This is necessary because char may be the equivalent of signed char, in
237 which case a byte where the top bit is set would be sign extended when
238 converting to int, yielding a value that is outside the range of un‐
239 signed char.
240
241 The details of what characters belong to which class depend on the lo‐
242 cale. For example, isupper() will not recognize an A-umlaut (Ä) as an
243 uppercase letter in the default C locale.
244
246 iswalnum(3), iswalpha(3), iswblank(3), iswcntrl(3), iswdigit(3), isw‐
247 graph(3), iswlower(3), iswprint(3), iswpunct(3), iswspace(3), iswup‐
248 per(3), iswxdigit(3), newlocale(3), setlocale(3), toascii(3),
249 tolower(3), toupper(3), uselocale(3), ascii(7), locale(7)
250
251
252
253Linux man-pages 6.04 2023-03-30 isalpha(3)