Character Classification and Conversion

Character classification functions

Category Functions in ctype.h Functions in wctype.h
Letters isalpha( ) iswalpha( )
Lowercase letters islower( ) iswlower( )
Uppercase letters isupper( ) iswupper( )
Decimal digits isdigit( ) iswdigit( )
Hexadecimal digits isxdigit( ) iswxdigit( )
Letters and decimal digits isalnum( ) iswalnum( )
Printable characters (including whitespace) isprint( ) iswprint( )
Printable, non-whitespace characters isgraph( ) iswgraph( )
Whitespace characters isspace( ) iswspace( )
Whitespace characters that separate words in a line of text isblank( ) iswblank( )
Punctuation marks ispunct( ) iswpunct( )
Control characters iscntrl( ) iswcntrl( )

The functions isgraph( ) and iswgraph( ) behave differently if the execution character set contains other byte-coded, printable, whitespace characters (that is, whitespace characters which are not control characters) in addition to the space character (‘ ‘). In that case, iswgraph( ) returns false for all such printable whitespace characters, while isgraph( ) returns false only for the space character (‘ ‘).

The header wctype.h also declares the two additional functions listed in Following Table to test wide characters. These are called the extensible classification functions, which you can use to test whether a wide-character value belongs to an implementation-defined category designated by a string.

Extensible character classification functions

Purpose Function
Map a string argument that designates a character class to a scalar value that can be used as the second argument to iswctype( ). wctype( )
Test whether a wide character belongs to the class designated by the second argument. iswctype( )

Case Mapping

The functions listed in Following Table yield the uppercase letter that corresponds to a given lowercase letter, and vice versa. All other argument values are returned unchanged.

Character conversion functions

Conversion Functions in ctype.h Functions in wctype.h
Upper- to lowercase tolower( ) towlower( )
Lower- to uppercase toupper( ) towupper( )