Description

Analyze if a char is ASCII. Returns true if the input char contains an ASCII character.

Syntax

Use the following function to evaluate a char variable:

isAscii(thisChar)

Parameters

The function admits the following parameter:

thisChar: char variable to evaluate. Allowed data types: char.

Returns

The function returns true if the evaluated input variable is ASCII.

Example Code

char myChar = 'A';  // try with 'é' for a non ASCII char

void setup() {
  Serial.begin(9600);

  if (isAscii(myChar)) {  // tests if myChar is an ASCII character
    Serial.println("The character is ASCII");
  } else {
    Serial.println("The character is not ASCII");
  }
}

void loop() {
}

See also