Internationalizing and Localizing Applications in Oracle Solaris

Exit Print View

Updated: July 2014
 
 

Integer Coded Character Classification Functions

The following functions are used for character classification and return a non-zero value for true, and 0 for false. With the exception of the isascii() function, all other functions are locale sensitive, specifically for the LC_CTYPE category of the current locale.

isalpha()

Test for an alphabetic character

isalnum()

Test for an alphanumeric character

isascii()

Test for a 7-bit US-ASCII character

isblank()

Test for a blank character

iscntrl()

Test for a control character

isdigit()

Test for a decimal digit

isgraph()

Test for a visible character

islower()

Test for a lowercase letter

isprint()

Test for a printable character

ispunct()

Test for a punctuation character

isspace()

Test for a white-space character

isupper()

Test for an uppercase letter

isxdigit()

Test for a hexadecimal digit

These functions should not be used in a locale with a multibyte codeset, such as UTF-8. Use the wide-character classification functions described in the following section for multibyte codesets.

The behavior of some of these functions also depends on the compiler options used at compile time. The ctype(3C) man page describes the "Default" and "Standard conforming" behaviors for isalpha(), isgraph(), isprint(), and isxdigit() functions. For example, isalpha() function is defined as follows:

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 the C locale, isalpha() returns true only for the characters for which isupper() or islower() is true.

This has consequences for languages or alphabets which have no case for its letters (also called unicase), such as Arabic, Hebrew or Thai. For alphabetic characters such as aleph (0xE0) in the Hebrew legacy locale he_IL.ISO8859-8, the functions isupper() and islower() always return false. Therefore, even the isalpha() function always returns false. If compiler options are enabled for the standard conforming behavior, the isalpha() function returns true for such characters. For more information, see the isalpha(3C) and standards(5) man pages.

See also the Oracle Solaris Studio 12.3: C User's Guide, ctype(3C), and SUSv3(5) man pages.