Go to main content

man pages section 3: Basic Library Functions

Exit Print View

Updated: Wednesday, July 27, 2022
 
 

isspace(3C)

Name

ctype, isalpha, isalnum, isascii, isblank, iscntrl, isdigit, islower, isprint, isspace, isupper, ispunct, isgraph, isxdigit, isalpha_l, isalnum_l, isblank_l, iscntrl_l, isdigit_l, isgraph_l, islower_l, isprint_l, ispunct_l, isspace_l, isupper_l, isxdigit_l - character handling

Synopsis

#include <ctype.h>

int isalpha(int c);
int isalnum(int c);
int isascii(int c);
int isblank(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int isalpha_l(int c, locale_t locale);
int isalnum_l(int c, locale_t locale);
int isblank_l(int c, locale_t locale);
int iscntrl_l(int c, locale_t locale);
int isdigit_l(int c, locale_t locale);
int isgraph_l(int c, locale_t locale);
int islower_l(int c, locale_t locale);
int isprint_l(int c, locale_t locale);
int ispunct_l(int c, locale_t locale);
int isspace_l(int c, locale_t locale);
int isupper_l(int c, locale_t locale);
int isxdigit_l(int c, locale_t locale);

Description

"These macros" here refers to interfaces listed in the NAME and SYNOPSIS sections, except those end their names with _l. Interfaces whose names end with _l are provided only as functions and they are described later in this section.

These macros classify character-coded integer values. Each is a predicate returning non-zero for true, 0 for false. The behavior of these macros, except isascii(), is affected by the current locale (see setlocale(3C)). To modify the behavior, change the LC_TYPE category in setlocale(), that is, setlocale(LC_CTYPE, newlocale). In the “C” locale, or in a locale where character type information is not defined, characters are classified according to the rules of the US-ASCII 7-bit coded character set.

The isascii() macro is defined on all integer values. The rest are defined only where the argument is an int, the value of which is representable as an unsigned char, or EOF, which is defined by the <stdio.h> header and represents end-of-file.

Functions exist for all the macros defined below. To get the function form, the macro name must be undefined (for example, #undef isdigit).

In addition to the SUSv4 conforming applications, if __XPG7_THREAD_MODEL__ is defined before including <ctype.h>, the following are provided as functions that are fully MT-Safe without any exceptions:

isalnum()
isalpha()
isblank()
iscntrl()
isdigit()
isgraph()
islower()
isprint()
ispunct()
isspace()
isupper()
isxdigit()
tolower()
toupper()

Unlike the macros corresponding to these functions that are not available with the __XPG7_THREAD_MODEL__ or the SUSv4 conformance, the following macros will still be available with the SUSv4 conformance and also with the __XPG7_THREAD_MODEL__ defined since they are not using any of the global variables and also inherently MT-Safe without any exceptions:

isascii()
toascii()

The isascii() and the toascii() functions are marked obsolescent by the SUSv4 standard. For more information, see the standards(7) man page.

Interfaces whose names end with _l are provided only as functions. Each of them is equivalent to corresponding function whose name doesn't end with _l, except that interface whose name ends with _l uses locale represented by <locale>.

For example, isalpha_l() is equivalent to function version of isalpha(), except that isalpha_l() uses locale represented by <locale>, instead of current locale.

The behavior is undefined if the <locale> argument to isalpha_l() is the special locale object LC_GLOBAL_LOCALE or is not a valid locale object handle.

For macros described with Default and Standard conforming versions, standard-conforming behavior is provided for standard-conforming applications (see standards(7)) and for applications that define __XPG4_CHAR_CLASS__ before including <ctype.h>.

Default

isalpha()

Tests for any character for which isupper() or islower() is true.

Standard conforming

isalpha()

Tests for any character for which isupper() or islower() is true, or any character that is one of the current locale-defined set of characters for which none of iscntrl(), isdigit(), ispunct(), or isspace() is true. In “C” locale, isalpha() returns true only for the characters for which isupper() or islower() is true.

isalnum()

Tests for any character for which isalpha() or isdigit() is true (letter or digit).

isascii()

Tests for any ASCII character, code between 0 and 0177 inclusive.

isblank()

Tests whether c is a character of class blank in the current locale. This macro/function is not available to applications conforming to standards prior to SUSv3. See standards(7)

iscntrl()

Tests for any control character as defined by the character set.

isdigit()

Tests for any decimal-digit character.

Default

isgraph()

Tests for any character for which ispunct(), isupper(), islower(), and isdigit() is true.

Standard conforming

isgraph()

Tests for any character for which isalnum() and ispunct() are true, or any character in the current locale-defined “graph” class which is neither a space (“ ”) nor a character for which iscntrl() is true.

islower()

Tests for any character that is a lowercase letter or is one of the current locale-defined set of characters for which none of iscntrl(), isdigit(), ispunct(), isspace (), or isupper() is true. In the “C” locale, islower() returns true only for the characters defined as lowercase ASCII characters.

Default

isprint()

Tests for any character for which ispunct(), isupper(), islower(), isdigit(), and the space character (“ ”) is true.

Standard conforming

isprint()

Tests for any character for which iscntrl() is false, and isalnum(), isgraph(), ispunct(), the space character (“ ”), and the characters in the current locale-defined “print” class are true.

ispunct()

Tests for any printing character which is neither a space (“ ”) nor a character for which isalnum() or iscntrl() is true.

isspace()

Tests for any space, tab, carriage-return, newline, vertical-tab or form-feed (standard white-space characters) or for one of the current locale-defined set of characters for which isalnum() is false. In the “C” locale, isspace() returns true only for the standard white-space characters.

isupper()

Tests for any character that is an uppercase letter or is one of the current locale-defined set of characters for which none of iscntrl(), isdigit(), ispunct(), isspace (), or islower() is true. In the “C” locale, isupper() returns true only for the characters defined as uppercase ASCII characters.

Default

isxdigit()

Tests for any hexadecimal-digit character ([0−9], [A−F], or [a−f]).

Standard conforming

isxdigit()

Tests for any hexadecimal-digit character ([0−9], [A−F], or [a−f] or the current locale-defined sets of characters representing the hexadecimal digits 10 to 15 inclusive). In the “C” locale, only

0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f

are included.

Return Values

If the argument to any of the character handling macros is not in the domain of the function, the result is undefined. If the argument <c> to any of the character handling macros and functions is not in the domain of the macro or function, the result is undefined. Otherwise, the macro or function returns non-zero if the classification is TRUE and 0 if the classification is FALSE.

Usage

The macros or functions whose names don't end with _l can be used safely in multithreaded applications, as long as setlocale(3C) is not being called to change the locale.

The functions whose names end with _l can be used safely in multithreaded applications.

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
CSI
Enabled
Interface Stability
Committed
MT-Level
MT-Safe
Standard

See Also

duplocale(3C), freelocale(3C), newlocale(3C), setlocale(3C), stdio(3C), uselocale(3C), ascii(7), environ(7), standards(7)