Name

toascii - convert character to ASCII

Library

libc.lib

Synopsis

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

Return values

The toascii function always returns a valid ASCII character.

Detailed description

The toascii function strips all the bits except the lower order 7 bits, which will be converted to unsigned character value that fits in the ASCII range.

Examples

#include<ctype.h> //toascii()
#include<stdio.h> //printf()
int test_toascii()
{
   int arr[]={’s’,’9’,’\r’,166, 255};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
     int ret = toascii(arr[i]); //call to the API with the chars in arr[]
     if( (!ret) != 0 )
     {
        printf("\n%d cannot convert", arr[i]);
     }
     else
     {
        printf("\n%c converted", arr[i]);
     }
}
printf("\n");
}


Output

s converted
9 converted
 converted
¦ converted
ÿ converted


See also

isalnum, isalpha, isascii, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, tolower, toupper, defns

Feedback

For additional information or queries on this page send feedback

© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.

Top