フォーマット
#include <ctype.h> int isascii(int c);
言語レベル: XPG4
スレッド・セーフ: はい。
ロケール依存: この関数の振る舞いは、 現行ロケールの LC_CTYPE カテゴリーの影響を受ける可能性があります。 この関数は、コンパイル・コマンドに対して LOCALETYPE(*CLD) が指定されている場合には使用できません。詳細については、CCSID およびロケールの理解を参照してください。
説明
指定した文字が現行ロケールで有効な 7 ビット US-ASCII 文字として表示可能な場合に、isascii() 関数はテストを行います。
戻り値
c が現行ロケールの 7 ビット US-ASCII 文字セットで表示可能な場合、isascii() 関数は非ゼロを戻します。 それ以外の場合は、0 を戻します。
isascii() の使用例
この例では、0x7c から 0x82 までの整数をテストし、整数が 7 ビット US-ASCII 文字セット内の文字で表示可能な場合は対応する文字を出力します。
#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 character is %c¥n", ch); else printf("Cannot be represented by an ASCII character¥n"); } return 0; } /************************************************ The output should be: 0x7c The character is @ 0x7d The character is ' 0x7e The character is = 0x7f The character is " 0x80 Cannot be represented by an ASCII character 0x81 The character is a 0x82 The character is b ************************************************/
関連情報