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