Skip to content

Characters

Calibre has a built-in char type for single characters.

let letter : char = 'A';
let newline : char = '\n';

Characters often appear when iterating through strings or converting strings to character lists.

let chars : list:<char> = "hello".to_chars();
print(chars[0]);

The stdlib provides helper methods on char, including:

  • .lowercase()
  • .uppercase()
  • .is_whitespace()
  • .is_digit()
  • .is_alphabetic()
  • .is_alphanumeric()

For example:

let c := 'A';
print(c.lowercase());
print(c.is_alphabetic());
print('7'.is_digit());
print(' '.is_whitespace());