isascii -- Test Integer Values

Format

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

Language Level: XPG4, Extension
isascii tests if an integer is within the ASCII range. This macro assumes that the system uses the ASCII character set.

Note: In earlier releases of the C/C++ run-time library, isascii began with an underscore (_isascii). Because it is defined by the X/Open standard, the underscore has been removed. For compatibility, IBM C and C++ Compilers will map _isascii to isascii for you.

Return Value
isascii returns a nonzero value if the integer is within the ASCII set, and 0 if it is not.

Example
This example tests the integers from 0x7c to 0x82, and prints the corresponding ASCII character if the integer is within the ASCII range.

#include <stdio.h>
#include <ctype.h>
int main(void)
{
   int ch;
   for (ch = 0x7c; ch <= 0x82; ch++) {
      printf("%#04x    ", ch);
      if (isascii(ch))
         printf("The ASCII character is %c\n", ch);
      else
         printf("Not an ASCII character\n");
   }
   return 0;
   /************************************************
      The output should be:
      0x7c    The ASCII character is |
      0x7d    The ASCII character is }
      0x7e    The ASCII character is ~
      0x7f    The ASCII character is &127
      0x80    Not an ASCII character
      0x81    Not an ASCII character
      0x82    Not an ASCII character
   ************************************************/
}


isalnum to isxdigit -- Test Integer Value
_iscsym - _iscsymf -- Test Integer
iswalnum to iswxdigit -- Test Wide Integer Value
_toascii - _tolower - _toupper -- Convert Character
tolower - toupper -- Convert Character Case
<ctype.h>