4.2 Diagnostics  -< ANSI C Rationale  -> 4.4 Localization                          Index 

4.3  Character Handling  <ctype.h>

Pains were taken to eliminate any ASCII dependencies from the definition of the character handling functions.  One notable result of this policy was the elimination of the function isascii, both because of the name and because its function was hard to generalize.  Nevertheless, the character functions are often most clearly explained in concrete terms, so ASCII is used frequently to express examples. 

Since these functions are often used primarily as macros, their domain is restricted to the small positive integers representable in an unsigned char, plus the value of EOF EOF is traditionally -1, but may be any negative integer, and hence distinguishable from any valid character code.  These macros may thus be efficiently implemented by using the argument as an index into a small array of attributes. 

The Standard (§4.13.1) warns that names beginning with is and to, when these are followed by lower-case letters, are subject to future use in adding items to <ctype.h>

4.3.1  Character testing functions

The definitions of printing character and control character have been generalized from ASCII. 

Note that none of these functions returns a nonzero value (true) for the argument value EOF

4.3.1.1  The isalnum function

4.3.1.2  The isalpha function

The Standard specifies that the set of letters, in the default locale, comprises the 26 upper-case and 26 lower-case letters of the Latin (English)  alphabet.  This set may vary in a locale-specific fashion (that is, under control of the setlocale function, §4.4 so long as

4.3.1.3  The iscntrl function

4.3.1.4  The isdigit function

4.3.1.5  The isgraph function

4.3.1.6  The islower function

4.3.1.7  The isprint function

4.3.1.8  The ispunct function

4.3.1.9  The isspace function

isspace is widely used within the library as the working definition of white space. 

4.3.1.10  The isupper function

4.3.1.11  The isxdigit function

4.3.2  Character case mapping functions

Earlier libraries had (almost equivalent) macros, _tolower and _toupper, for these functions.  The Standard now permits any library function to be additionally implemented as a macro; the underlying function must still be present.  _toupper and _tolower are thus unnecessary and were dropped as part of the general standardization of library macros. 

4.3.2.1  The tolower function

4.3.2.2  The toupper function


4.2 Diagnostics  -< ANSI C Rationale  -> 4.4 Localization                          Index