xref: /illumos-gate/usr/src/man/man3c/ctype.3c (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)

Sun Microsystems, Inc. gratefully acknowledges The Open Group for
permission to reproduce portions of its copyrighted documentation.
Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.

The Institute of Electrical and Electronics Engineers and The Open
Group, have given us permission to reprint portions of their
documentation.

In the following statement, the phrase ``this text'' refers to portions
of the system documentation.

Portions of this text are reprinted and reproduced in electronic form
in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
Standard for Information Technology -- Portable Operating System
Interface (POSIX), The Open Group Base Specifications Issue 6,
Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
Engineers, Inc and The Open Group. In the event of any discrepancy
between these versions and the original IEEE and The Open Group
Standard, the original IEEE and The Open Group Standard is the referee
document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html.

This notice shall appear on any product containing this material.

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]


Copyright 1989 AT&T.
Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
Portions Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
Copyright 2014 Garrett D'Amore <garrett@damore.org>
Copyright 2016 Joyent, Inc.

CTYPE 3C "November 8, 2020"
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, islower_l, isprint_l, isspace_l, isupper_l, ispunct_l, isgraph_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 loc);

int isalnum_l(int c, locale_t loc);

int isblank_l(int c, locale_t loc);

int iscntrl_l(int c, locale_t loc);

int isdigit_l(int c, locale_t loc);

int isgraph_l(int c, locale_t loc);

int islower_l(int c, locale_t loc);

int isprint_l(int c, locale_t loc);

int ispunct_l(int c, locale_t loc);

int isspace_l(int c, locale_t loc);

int isupper_l(int c, locale_t loc);

int isxdigit_l(int c, locale_t loc);
DESCRIPTION
These functions 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) and uselocale(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 functions isalnum_l(), isalpha_l(), isblank_l(), iscntrl_l, isdigit_l(), isgraph_l(), islower_l(), isprint_l(), ispunct_l(), isspace_l(), isupper_l(), and isxdigit_l() all behave identically to their counterparts without the '_l' prefix, except that instead of acting on the current locale, they perform the test on the locale specified in the argument loc.

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. 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.

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 lower-case 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 lower-case ASCII characters.

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 upper-case 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 upper-case ASCII characters.

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. Otherwise, the macro or function returns non-zero if the classification is TRUE and 0 if the classification is FALSE.
ATTRIBUTES
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE ATTRIBUTE VALUE
CSI Enabled
Interface Stability Standard
MT-Level MT-Safe
SEE ALSO
newlocale (3C), setlocale (3C), stdio (3C), uselocale (3C), ascii (7), environ (7), standards (7)