toascii() — Convert Character to Character Representable by ASCII
Format
#include <ctype.h>
int toascii(int c);
Language Level
XPG4
Threadsafe
Yes
Locale Sensitive
The behavior of this function might be affected by the LC_CTYPE category of the current locale. This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.
Description
The toascii()
function
determines to what character c would be mapped to in a 7–bit
US-ASCII locale and returns the corresponding character encoding in
the current locale.
Return Value
The toascii()
function
maps the character c according to a 7–bit US-ASCII locale and
returns the corresponding character encoding in the current locale.
Example
This example prints encodings of
the 7–bit US-ASCII characters 0x7c to 0x82 are mapped to by
toascii()
.
#include <stdio.h>
#include <ctype.h>
void main(void)
{
int ch;
for (ch=0x7c; ch<=0x82; ch++) {
printf("toascii(%#04x) = %c\n", ch, toascii(ch));
}
}
/*****************And the output should be:********************************
toascii(0x7c) = @
toascii(0x7d) = '
toascii(0x7e) = =
toascii(0x7f) = "
toascii(0x80) = X
toascii(0x81) = a
toascii(0x82) = b
**********************************************************************/