ILE C/C++ Run-Time Library Functions


toascii() -- Convert Character to Character Representable by ASCII

Format

#include <ctype.h>
int toascii(int c);

Language Level: XPG4

Threadsafe: Yes.

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 that uses toascii()

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
**********************************************************************/

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]