DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

toascii(S-osr5)


toascii, todigit, toint, tolower, _tolower, toupper, _toupper -- routines used to translate characters

Syntax

cc . . . -lc

#include  <ctype.h>

int toascii(int c);

int todigit(int c);

int toint(int c);

int tolower(int c);

int _tolower(int c);

int toupper(int c);

int _toupper(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 getc(S-osr5)). If the argument of toupper represents a lowercase letter (for which islower is true), the result is the corresponding uppercase letter. If the argument of tolower represents an uppercase letter (for which isupper is true), the result is the corresponding lowercase letter. All other arguments are returned unchanged.

The macros _toupper and _tolower have the same functionality of the functions on valid input, but the macros are faster because they do not do range checking. The _toupper macro takes a lowercase letter as its argument. The result is the corresponding uppercase letter. The _tolower macro takes an uppercase letter as its argument. The result is the corresponding lowercase letter. All other arguments 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 of these conversion 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-osr5)

Standards conformance

toascii is conformant with:

X/Open Portability Guide, Issue 3, 1989 .

tolower and toupper are conformant with:

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 .

_tolower and _toupper are conformant with:

X/Open Portability Guide, Issue 3, 1989 .


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005