toascii(S) 6 January 1993 toascii(S) Name toascii, todigit, toint, tolower, _tolower, toupper, _toupper - routines used to translate characters Syntax cc . . . -lc #include <ctype.h> int toascii(c) int c; int todigit(i) int i; int toint(c) int c; int tolower(c) int c; int _tolower(c) int c; int toupper(c) int c; int _toupper(c) int c; Description The functions toupper and tolower convert the argument c to a letter of the opposite case. Arguments may be the integers -1 to 255 (the same values returned by get(S)). If the argument of toupper represents a lowercase letter, the result is the corresponding uppercase letter. If the argument of tolower represents an uppercase letter, the result is the corresponding lowercase letter. All other arguments are returned unchanged. The effect of the macros toupper and tolower is the same as toupper and tolower. The advantage of toupper and tolower is that they have re- stricted argument values and are faster. The toupper macro takes a lowercase letter as its argument. The result is the corresponding upper- case letter. The tolower macro takes an uppercase letter as its argu- ment. The result is the corresponding lowercase letter. All other argu- ments cause unpredictable results. The macro toascii yields its argument with all bits cleared that are not part of a standard ASCII character; it is intended for compatibility with other systems. The macro todigit returns the digit character corresponding to its integer argument. The argument must be in the range 0-9, otherwise the behavior is undefined. The macro toint returns the integer corresponding to the digit character supplied as its argument. The argument must be one of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, otherwise the behavior is undefined. Notes The routines toupper, tolower and toascii are implemented as macros, and on other systems, toupper and tolower may be implemented as macros. On this system, all conv(S) routines evaluate their arguments once and once only. It is, however, good practice to ensure that macros are not called with arguments that have side effects which differ if they are evaluated more than once. An example of such a macro is: toupper(*p++) Avoiding such argument calls helps to keep code portable. The functions toupper and tolower are library functions. Their arguments are converted to integers. For this reason, care should be taken that character arguments are supplied as unsigned characters to avoid problems with sign-extension of 8-bit character values. The todigit and toint macros are extensions, and may not be present on other systems. See also ctype(S) Standards conformance toascii is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989. tolower and toupper are conformant with: AT&T SVID Issue 2; X/Open Portability Guide, Issue 3, 1989; ANSI X3.159-1989 Programming Language -- C; IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1); and NIST FIPS 151-1.