
#include <lctype.h> int isascii(int c);
isascii tests an integer value c to determine whether it is
the EBCDIC equivalent of a character belonging to the ASCII character set.
isascii returns 0 if the character is not ASCII, or a nonzero value
if it is ASCII. If the argument does not have a char value, 0 is returned.
isascii returns either 0 or 1.
isascii in a program that
you expect to be portable. Traditionally, isascii is used to
determine whether an integer is a valid character. Unfortunately, in
an EBCDIC environment, the name and the function do not mesh well.
This implementation defines the isebcdic function to test for
validity as a char value and defines isascii as stated above.
Therefore, many programs that use isascii should be changed to use
isebcdic when running on the mainframe, unless the intent is to test for
membership in the ASCII character set without regard to the native character
set of the hardware on which the program is executed.
isascii is implemented by a true function. isascii tests a
character to see whether it is the EBCDIC equivalent of a character in the
ASCII character set. This does not produce the same value as the following
statement:
((unsigned) c) < 128This statement frequently implements
isascii in a C implementation
that uses ASCII as its native character set.
Also note that isascii('\n') has the value 0.
#include <lctype.h>
#include <stdio.h>
main()
{
char input;
puts("Enter a character: ");
input = getc();
if (isascii(input) && !iscntrl(input)){
puts(" The character you typed is standard ASCII, ");
puts(" and it is not a control character.");
}
else if(!isascii(input) || iscntrl(input){
puts(" The character you typed is not a standard ASCII");
puts(" character, or it is a control character.");
}
}
isebcdic
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.