Changes: Ready for 5.13
[man-pages.git] / man3 / isalpha.3
blobdb6edae2f135ece13c93a13866688f58c5b9132e
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified Sat Jul 24 19:10:00 1993 by Rik Faith (faith@cs.unc.edu)
26 .\" Modified Sun Aug 21 17:51:50 1994 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified Sat Sep  2 21:52:01 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
28 .\" Modified Mon May 27 22:55:26 1996 by Martin Schulze (joey@linux.de)
29 .\"
30 .TH ISALPHA 3 2021-03-22 "GNU" "Linux Programmer's Manual"
31 .SH NAME
32 isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower,
33 isprint, ispunct, isspace, isupper, isxdigit,
34 isalnum_l, isalpha_l, isascii_l, isblank_l, iscntrl_l,
35 isdigit_l, isgraph_l, islower_l,
36 isprint_l, ispunct_l, isspace_l, isupper_l, isxdigit_l
37 \- character classification functions
38 .SH SYNOPSIS
39 .nf
40 .B #include <ctype.h>
41 .PP
42 .BI "int isalnum(int " c );
43 .BI "int isalpha(int " c );
44 .BI "int iscntrl(int " c );
45 .BI "int isdigit(int " c );
46 .BI "int isgraph(int " c );
47 .BI "int islower(int " c );
48 .BI "int isprint(int " c );
49 .BI "int ispunct(int " c );
50 .BI "int isspace(int " c );
51 .BI "int isupper(int " c );
52 .BI "int isxdigit(int " c );
53 .PP
54 .BI "int isascii(int " c );
55 .BI "int isblank(int " c );
56 .PP
57 .BI "int isalnum_l(int " c ", locale_t " locale );
58 .BI "int isalpha_l(int " c ", locale_t " locale );
59 .BI "int isblank_l(int " c ", locale_t " locale );
60 .BI "int iscntrl_l(int " c ", locale_t " locale );
61 .BI "int isdigit_l(int " c ", locale_t " locale );
62 .BI "int isgraph_l(int " c ", locale_t " locale );
63 .BI "int islower_l(int " c ", locale_t " locale );
64 .BI "int isprint_l(int " c ", locale_t " locale );
65 .BI "int ispunct_l(int " c ", locale_t " locale );
66 .BI "int isspace_l(int " c ", locale_t " locale );
67 .BI "int isupper_l(int " c ", locale_t " locale );
68 .BI "int isxdigit_l(int " c ", locale_t " locale );
69 .PP
70 .BI "int isascii_l(int " c ", locale_t " locale );
71 .fi
72 .PP
73 .RS -4
74 Feature Test Macro Requirements for glibc (see
75 .BR feature_test_macros (7)):
76 .RE
77 .ad l
78 .PP
79 .BR isascii ():
80 .nf
81     _XOPEN_SOURCE
82         || /* Glibc since 2.19: */ _DEFAULT_SOURCE
83         || /* Glibc <= 2.19: */ _SVID_SOURCE
84 .fi
85 .PP
86 .BR isblank ():
87 .nf
88     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
89 .fi
90 .nh
91 .PP
92 .BR isalnum_l (),
93 .BR isalpha_l (),
94 .BR isblank_l (),
95 .BR iscntrl_l (),
96 .BR isdigit_l (),
97 .BR isgraph_l (),
98 .BR islower_l (),
99 .BR isprint_l (),
100 .BR ispunct_l (),
101 .BR isspace_l (),
102 .BR isupper_l (),
103 .BR isxdigit_l ():
106     Since glibc 2.10:
107         _XOPEN_SOURCE >= 700
108     Before glibc 2.10:
109         _GNU_SOURCE
112 .BR isascii_l ():
114     Since glibc 2.10:
115         _XOPEN_SOURCE >= 700 && (_SVID_SOURCE || _BSD_SOURCE)
116     Before glibc 2.10:
117         _GNU_SOURCE
120 .SH DESCRIPTION
121 These functions check whether
122 .IR c ,
123 which must have the value of an
124 .I unsigned char
126 .BR EOF ,
127 falls into a certain character class according to the specified locale.
128 The functions without the
129 "_l" suffix perform the check based on the current locale.
131 The functions with the "_l" suffix perform the check
132 based on the locale specified by the locale object
133 .IR locale .
134 The behavior of these functions is undefined if
135 .I locale
136 is the special locale object
137 .B LC_GLOBAL_LOCALE
138 (see
139 .BR duplocale (3))
140 or is not a valid locale object handle.
142 The list below explains the operation of the functions without
143 the "_l" suffix;
144 the functions with the "_l" suffix differ only in using the locale object
145 .I locale
146 instead of the current locale.
148 .BR isalnum ()
149 checks for an alphanumeric character; it is equivalent to
150 .BI "(isalpha(" c ") || isdigit(" c "))" \fR.
152 .BR isalpha ()
153 checks for an alphabetic character; in the standard \fB"C"\fP
154 locale, it is equivalent to
155 .BI "(isupper(" c ") || islower(" c "))" \fR.
156 In some locales, there may be additional characters for which
157 .BR isalpha ()
158 is true\(emletters which are neither uppercase nor lowercase.
160 .BR isascii ()
161 checks whether \fIc\fP is a 7-bit
162 .I unsigned char
163 value that fits into
164 the ASCII character set.
166 .BR isblank ()
167 checks for a blank character; that is, a space or a tab.
169 .BR iscntrl ()
170 checks for a control character.
172 .BR isdigit ()
173 checks for a digit (0 through 9).
175 .BR isgraph ()
176 checks for any printable character except space.
178 .BR islower ()
179 checks for a lowercase character.
181 .BR isprint ()
182 checks for any printable character including space.
184 .BR ispunct ()
185 checks for any printable character which is not a space or an
186 alphanumeric character.
188 .BR isspace ()
189 checks for white-space characters.
190 In the
191 .B """C"""
193 .B """POSIX"""
194 locales, these are: space, form-feed
195 .RB ( \(aq\ef\(aq ),
196 newline
197 .RB ( \(aq\en\(aq ),
198 carriage return
199 .RB ( \(aq\er\(aq ),
200 horizontal tab
201 .RB ( \(aq\et\(aq ),
202 and vertical tab
203 .RB ( \(aq\ev\(aq ).
205 .BR isupper ()
206 checks for an uppercase letter.
208 .BR isxdigit ()
209 checks for hexadecimal digits, that is, one of
211 .BR "0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F" .
212 .SH RETURN VALUE
213 The values returned are nonzero if the character
214 .I c
215 falls into the tested class, and zero if not.
216 .SH VERSIONS
217 .BR isalnum_l (),
218 .BR isalpha_l (),
219 .BR isblank_l (),
220 .BR iscntrl_l (),
221 .BR isdigit_l (),
222 .BR isgraph_l (),
223 .BR islower_l (),
224 .BR isprint_l (),
225 .BR ispunct_l (),
226 .BR isspace_l (),
227 .BR isupper_l (),
228 .BR isxdigit_l (),
230 .BR isascii_l ()
231 are available since glibc 2.3.
232 .SH ATTRIBUTES
233 For an explanation of the terms used in this section, see
234 .BR attributes (7).
235 .ad l
238 allbox;
239 lbx lb lb
240 l l l.
241 Interface       Attribute       Value
243 .BR isalnum (),
244 .BR isalpha (),
245 .BR isascii (),
246 .BR isblank (),
247 .BR iscntrl (),
248 .BR isdigit (),
249 .BR isgraph (),
250 .BR islower (),
251 .BR isprint (),
252 .BR ispunct (),
253 .BR isspace (),
254 .BR isupper (),
255 .BR isxdigit ()
256 T}      Thread safety   MT-Safe
260 .sp 1
261 .\" FIXME: need a thread-safety statement about the *_l functions
262 .SH CONFORMING TO
263 C89 specifies
264 .BR isalnum (),
265 .BR isalpha (),
266 .BR iscntrl (),
267 .BR isdigit (),
268 .BR isgraph (),
269 .BR islower (),
270 .BR isprint (),
271 .BR ispunct (),
272 .BR isspace (),
273 .BR isupper (),
275 .BR isxdigit (),
276 but not
277 .BR isascii ()
279 .BR isblank ().
280 POSIX.1-2001
281 also specifies those functions, and also
282 .BR isascii ()
283 (as an XSI extension)
285 .BR isblank ().
286 C99 specifies all of the preceding functions, except
287 .BR isascii ().
289 POSIX.1-2008 marks
290 .BR isascii ()
291 as obsolete,
292 noting that it cannot be used portably in a localized application.
294 POSIX.1-2008 specifies
295 .BR isalnum_l (),
296 .BR isalpha_l (),
297 .BR isblank_l (),
298 .BR iscntrl_l (),
299 .BR isdigit_l (),
300 .BR isgraph_l (),
301 .BR islower_l (),
302 .BR isprint_l (),
303 .BR ispunct_l (),
304 .BR isspace_l (),
305 .BR isupper_l (),
307 .BR isxdigit_l ().
309 .BR isascii_l ()
310 is a GNU extension.
311 .SH NOTES
312 The standards require that the argument
313 .I c
314 for these functions is either
315 .B EOF
316 or a value that is representable in the type
317 .IR "unsigned char" .
318 If the argument
319 .I c
320 is of type
321 .IR char ,
322 it must be cast to
323 .IR "unsigned char" ,
324 as in the following example:
326 .in +4n
328 char c;
329 \&...
330 res = toupper((unsigned char) c);
334 This is necessary because
335 .I char
336 may be the equivalent of
337 .IR "signed char" ,
338 in which case a byte where the top bit is set would be sign extended when
339 converting to
340 .IR int ,
341 yielding a value that is outside the range of
342 .IR "unsigned char" .
344 The details of what characters belong to which class depend on the
345 locale.
346 For example,
347 .BR isupper ()
348 will not recognize an A-umlaut (\(:A) as an uppercase letter in the default
349 .B "C"
350 locale.
351 .SH SEE ALSO
352 .BR iswalnum (3),
353 .BR iswalpha (3),
354 .BR iswblank (3),
355 .BR iswcntrl (3),
356 .BR iswdigit (3),
357 .BR iswgraph (3),
358 .BR iswlower (3),
359 .BR iswprint (3),
360 .BR iswpunct (3),
361 .BR iswspace (3),
362 .BR iswupper (3),
363 .BR iswxdigit (3),
364 .BR newlocale (3),
365 .BR setlocale (3),
366 .BR toascii (3),
367 .BR tolower (3),
368 .BR toupper (3),
369 .BR uselocale (3),
370 .BR ascii (7),
371 .BR locale (7)