Description

Analyze if a char is printable (that is any character that produces an output, even a blank space). Returns true if the input char is printable.

Syntax

Use the following function to evaluate a char variable:

isPrintable(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 printable.

Example Code

char myChar = ' ';  // try with '\n' for a non printable char

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

  if (isPrintable(myChar)) {  // tests if myChar is printable char
    Serial.println("The character is printable");
  } else {
    Serial.println("The character is not printable");
  }
}

void loop() {
}

See also