NAME |LIBRARY |SYNOPSIS |DESCRIPTION |RETURN VALUE |ATTRIBUTES |STANDARDS |HISTORY |CAVEATS |SEE ALSO |COLOPHON | |
isalpha(3) Library Functions Manualisalpha(3)isalnum, isalpha, isascii, isblank, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, isalnum_l, isalpha_l, isascii_l, isblank_l, iscntrl_l, isdigit_l, isgraph_l, islower_l, isprint_l, ispunct_l, isspace_l, isupper_l, isxdigit_l - character classification functions
Standard C library (libc,-lc)
#include <ctype.h>int isalnum(intc);int isalpha(intc);int iscntrl(intc);int isdigit(intc);int isgraph(intc);int islower(intc);int isprint(intc);int ispunct(intc);int isspace(intc);int isupper(intc);int isxdigit(intc);int isascii(intc);int isblank(intc);int isalnum_l(intc, locale_tlocale);int isalpha_l(intc, locale_tlocale);int isblank_l(intc, locale_tlocale);int iscntrl_l(intc, locale_tlocale);int isdigit_l(intc, locale_tlocale);int isgraph_l(intc, locale_tlocale);int islower_l(intc, locale_tlocale);int isprint_l(intc, locale_tlocale);int ispunct_l(intc, locale_tlocale);int isspace_l(intc, locale_tlocale);int isupper_l(intc, locale_tlocale);int isxdigit_l(intc, locale_tlocale);int isascii_l(intc, locale_tlocale); Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):isascii(): _XOPEN_SOURCE || /* glibc >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _SVID_SOURCEisblank(): _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112Lisalnum_l(),isalpha_l(),isblank_l(),iscntrl_l(),isdigit_l(),isgraph_l(),islower_l(),isprint_l(),ispunct_l(),isspace_l(),isupper_l(),isxdigit_l(): Since glibc 2.10: _XOPEN_SOURCE >= 700 Before glibc 2.10: _GNU_SOURCEisascii_l(): Since glibc 2.10: _XOPEN_SOURCE >= 700 && (_SVID_SOURCE || _BSD_SOURCE) Before glibc 2.10: _GNU_SOURCE
These functions check whetherc, which must have the value of anunsigned char orEOF, falls into a certain character class according to the specified locale. The functions without the "_l" suffix perform the check based on the current locale. The functions with the "_l" suffix perform the check based on the locale specified by the locale objectlocale. The behavior of these functions is undefined iflocale is the special locale objectLC_GLOBAL_LOCALE(seeduplocale(3)) or is not a valid locale object handle. The list below explains the operation of the functions without the "_l" suffix; the functions with the "_l" suffix differ only in using the locale objectlocale instead of the current locale.isalnum() checks for an alphanumeric character; it is equivalent to(isalpha(c) || isdigit(c)).isalpha() checks for an alphabetic character; in the standard"C" locale, it is equivalent to(isupper(c) || islower(c)). In some locales, there may be additional characters for whichisalpha() is true—letters which are neither uppercase nor lowercase.isascii() checks whetherc is a 7-bitunsigned char value that fits into the ASCII character set.isblank() checks for a blank character; that is, a space or a tab.iscntrl() checks for a control character.isdigit() checks for a digit (0 through 9).isgraph() checks for any printable character except space.islower() checks for a lowercase character.isprint() checks for any printable character including space.ispunct() checks for any printable character which is not a space or an alphanumeric character.isspace() checks for white-space characters. In the"C"and"POSIX" locales, these are: space, form-feed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v').isupper() checks for an uppercase letter.isxdigit() checks for hexadecimal digits, that is, one of0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F.The values returned are nonzero if the characterc falls into the tested class, and zero if not.
For an explanation of the terms used in this section, seeattributes(7). ┌──────────────────────────────────────┬───────────────┬─────────┐ │Interface│Attribute│Value│ ├──────────────────────────────────────┼───────────────┼─────────┤ │isalnum(),isalpha(),isascii(), │ Thread safety │ MT-Safe │ │isblank(),iscntrl(),isdigit(), │ │ │ │isgraph(),islower(),isprint(), │ │ │ │ispunct(),isspace(),isupper(), │ │ │ │isxdigit() │ │ │ └──────────────────────────────────────┴───────────────┴─────────┘
isalnum()isalpha()iscntrl()isdigit()isgraph()islower()isprint()ispunct()isspace()isupper()isxdigit()isblank() C11, POSIX.1-2008.isascii()isalnum_l()isalpha_l()isblank_l()iscntrl_l()isdigit_l()isgraph_l()islower_l()isprint_l()ispunct_l()isspace_l()isupper_l()isxdigit_l() POSIX.1-2008.isascii_l() GNU.
isalnum()isalpha()iscntrl()isdigit()isgraph()islower()isprint()ispunct()isspace()isupper()isxdigit() C89, POSIX.1-2001.isblank() C99, POSIX.1-2001.isascii() POSIX.1-2001 (XSI). POSIX.1-2008 marks it as obsolete, noting that it cannot be used portably in a localized application.isalnum_l()isalpha_l()isblank_l()iscntrl_l()isdigit_l()isgraph_l()islower_l()isprint_l()ispunct_l()isspace_l()isupper_l()isxdigit_l() glibc 2.3. POSIX.1-2008.isascii_l() glibc 2.3.
The standards require that the argumentc for these functions is eitherEOFor a value that is representable in the typeunsignedchar; otherwise, the behavior is undefined. If the argumentc is of typechar, it must be cast tounsigned char, as in the following example: char c; ... res = toupper((unsigned char) c); This is necessary becausechar may be the equivalent ofsignedchar, in which case a byte where the top bit is set would be sign extended when converting toint, yielding a value that is outside the range ofunsigned char. The details of what characters belong to which class depend on the locale. For example,isupper() will not recognize an A-umlaut (Ä) as an uppercase letter in the defaultClocale.
iswalnum(3),iswalpha(3),iswblank(3),iswcntrl(3),iswdigit(3),iswgraph(3),iswlower(3),iswprint(3),iswpunct(3),iswspace(3),iswupper(3),iswxdigit(3),newlocale(3),setlocale(3),toascii(3),tolower(3),toupper(3),uselocale(3),ascii(7),locale(7)
This page is part of theman-pages (Linux kernel and C library user-space interface documentation) project. Information about the project can be found at ⟨https://www.kernel.org/doc/man-pages/⟩. If you have a bug report for this manual page, see ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩. This page was obtained from the tarball man-pages-6.15.tar.gz fetched from ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on 2025-08-11. If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up- to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgLinux man-pages 6.15 2025-05-17isalpha(3)Pages that refer to this page:bash(1), PR_SET_VMA(2const), getopt(3), iswalnum(3), iswalpha(3), iswblank(3), iswcntrl(3), iswdigit(3), iswgraph(3), iswlower(3), iswprint(3), iswpunct(3), iswspace(3), iswupper(3), iswxdigit(3), localeconv(3), setlocale(3), sscanf(3), strtod(3), strtol(3), strtoul(3), toascii(3), toupper(3), wctype(3), bpf-helpers(7), locale(7), lsof(8)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |