Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ascii(7)

setlocale(3C)

CTYPE(3)                             BSD                              CTYPE(3)



NAME
     ctype: isalpha, isupper, islower, isdigit, isxdigit, isalnum, isspace,
     ispunct, isprint, isgraph, iscntrl, isascii, toupper, tolower, _toupper,
     _tolower, toascii - classify characters

SYNOPSIS
     #include <ctype.h>

     int isalpha (c)
     int c;

     . . .

DESCRIPTION
     The following character-handling  functions test whether c is a specific
     type of character or digit, according to the following definitions:

     isalpha    c is an alphabetic character (letter)

     isupper    c is any uppercase letter as defined by the character set.

     islower    c is any lowercase letter as defined by the character set.

     isdigit    c is a digit [0-9]. The decimal digits are independent of the
                codeset in use.

     isxdigit   c is a hexadecimal digit [0-9], [A-F] or [a-f]. The
                hexadecimal digits are independent of the codeset in use.

     isalnum    c is an alphanumeric character. Alphanumeric characters are
                those for which isalpha or isdigit is true.

     isspace    c is a space, tab, carriage return, newline, vertical tab, or
                form-feed in the C locale.

     ispunct    c is any punctuation character (that is, any printing
                character except the space character (040), digits or letters
                in US-ASCII).

     isprint    c is a printing character (that is a space or any character
                for which isalnum or ispunct is true or any other "printing
                character" as defined by the character set.

     isgraph    c is any character with visible representation (e.g., printing
                characters excluding the space character (040) in ASCII).

     iscntrl    c is any "control character" defined by the character set.

     isascii    c is a US-ASCII 7-bit character.


     Character Classification
     For all the above character-handling functions (except isascii, isdigit,
     and isxdigit), the following is true:

          The functions classify character-coded integer values according to
          the rules of the coded character set defined by character type
          information in the program's locale (category LC_CTYPE).

          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.

     For all character-handling functions, the argument is an int, the value
     of which must be represented as an unsigned char or must equal the value
     of the macro EOF (defined in stdio.h).  EOF is guaranteed not to be a
     character set member.  If the argument has any other value, the behavior
     is undefined.

     Character-Conversion Functions (toupper, tolower,  _toupper,  _tolower,
     toascii)
     The toupper, tolower,  _toupper,  _tolower, functions and macros convert
     their arguments from lowercase (uppercase) to uppercase (lowercase).
     These functions and macros do a table lookup; the table gets initialized
     in ways depending upon whether or not a call to setlocale(3) has been
     made.

     If c is a character for which islower is true, toupper returns the
     corresponding uppercase character, if it exists.  Otherwise, toupper
     returns c.  If c is a character for which isupper is true, tolower
     returns the corresponding lowercase character, if it exists.  Otherwise,
     tolower returns c.

     Character conversions are performed according to the rules defined by
     character type information in a program's locale (category LC_CTYPE).

     The macros _toupper and _tolower are not part of interfaces defined in
     ANSI X3.159, but are part of XPG/3 (1988).  These macros accomplish the
     same thing as toupper and tolower, but have restricted domains and are
     faster.  If c is outside their domain, _toupper and _tolower return
     undefined values.

     In the C locale, or in a locale where case conversion information is not
     defined, this function determines the case of characters according to the
     rules of the ASCII-coded character set. Characters outside the ASCII
     range of characters are returned unchanged.

     The toascii function converts its argument into a 7-bit ASCII character.

DIAGNOSTICS
     The isalpha function returns a nonzero if c is an alphabetic character;
     otherwise, it returns zero.

     The isupper function returns a nonzero if c is an uppercase character;
     otherwise, it returns zero.

     The islower function returns a nonzero if c is a lowercase character;
     otherwise, it returns zero.

     The isdigit function returns a nonzero if c is a decimal digit;
     otherwise, it returns zero.

     The isxdigit function returns a nonzero if c is a hexadecimal digit;
     otherwise, it returns zero.

     The isalnum function returns a nonzero if isalpha or isdigit would return
     zero; otherwise, it returns zero.

     The isspace function returns a nonzero if c is a whitespace character;
     otherwise, it returns zero.

     The ispunct function returns a nonzero if c is a punctuation character;
     otherwise, it returns zero.

     The isprint function returns a nonzero if c is a printing character;
     otherwise, it returns zero.

     The isgraph function returns a nonzero if c is a character with a visible
     representation; otherwise, it returns zero.

     The iscntrl function returns a nonzero if c is a control character;
     otherwise, it returns zero.

     The isascii function returns a nonzero if c is an ASCII character code
     between zero and 0177, inclusive; otherwise, it returns zero.

     If the argument to any of these functions is not in the domain of the
     function, the result is undefined.

     If the argument is a character for which isupper is true and there is a
     corresponding character for which islower is true, the toupper or tolower
     functions return the corresponding character. Otherwise, the argument is
     returned unchanged.

     The toascii function returns the value (c & 0x7f).

     No errors are defined for _toupper or _tolower.

NOTES
     To be compatible with common C usage, have the functions defined as
     macros by adding the directive

          #define _CLASSIC_CTYPE_MACROS

     before any #include directives in your program.

SEE ALSO
     ascii(7), setlocale(3C), <ctype.h>, <stdio.h> <ctype.h>

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026