### _toascii - _tolower - _toupper -- Convert Character

Format

>     #include <ctype.h>
>     int _toascii(int c);
>     int _tolower(int c);
>     int _toupper(int c);

Language Level: Extension
_toascii converts c to a character in the ASCII character set, by setting all but the low-order 7 bits to 0. If c already represents an ASCII character, _toascii does not change it.

_tolower converts c to the corresponding lowercase letter, if possible.

_toupper converts c to the corresponding uppercase letter, if possible.

Important: Use _tolower and _toupper only when you know that c is uppercase A to Z or lowercase a to z, respectively. Otherwise the results are undefined. These functions are not affected by the current locale.

These are all macros, and do not correctly handle arguments with side effects.

For portability, use the tolower and toupper functions defined by the ANSI/ISO standard, instead of the _tolower and _toupper macros.

Return Value
_toascii, _tolower, and _toupper return the possibly converted character c. If the character passed to _toascii is an ASCII character, _toascii returns the character unchanged. There is no error return.

Example
This example prints four sets of characters. The first set is the ASCII characters having graphic images, which range from 0x21 through 0x7e. The second set takes integers 0x7f21 through 0x7f7e and applies the _toascii macro to them, yielding the same set of printable characters. The third set is the characters with all lowercase letters converted to uppercase. The fourth set is the characters with all uppercase letters converted to lowercase.

    #include <stdio.h>
    #include <ctype.h>

    int main(void)
    {
       int ch;

       printf("Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to\n");
       printf("ASCII by _toascii() both yield the same graphic characters.\n\n");
       for (ch = 0x01; ch <= 0x03; ch++) {
          printf("char 0x%.4X: %c    ", ch, ch);
          printf("char _toascii(0x%.4X): %c\n", ch+0x7f00, ch+0x7f00);
       }
       printf("\nCharacters A, B and C converted to lower case and\n");
       printf("Characters a, b and c converted to upper case.\n\n");
       for (ch = 0x41; ch <= 0x43; ch++) {
          printf("_tolower(%c) = %c   ", ch, _tolower(ch));
          printf("_toupper(%c) = %c\n", ch+0x20, _toupper(ch+0x20));
       }
       return 0;

       /**************************************************************************
          The output should be:

          Characters 0x01 to 0x03, and integers 0x7f01 to 0x7f03 mapped to
          ASCII by _toascii() both yield the same graphic characters.

          char 0x0001:     char _toascii(0x7F01):
          char 0x0002:     char _toascii(0x7F02):
          char 0x0003:     char _toascii(0x7F03):

          Characters A, B and C converted to lower case and
          Characters a, b and c converted to upper case.

          _tolower(A) = a   _toupper(a) = A
          _tolower(B) = b   _toupper(b) = B
          _tolower(C) = c   _toupper(c) = C
       **************************************************************************/
    }

isalnum to isxdigit -- Test Integer Value
isascii -- Test Integer Values
_iscsym - _iscsymf -- Test Integer
tolower() - toupper() -- Convert Character Case
towlower - towupper -- Convert Wide Character Case
<ctype.h>