Char

A Char represents a 32-bit Unicode code point.

It is typically created with a char literal by enclosing an UTF-8 character in single quotes.

  1. 'a'
  2. 'z'
  3. '0'
  4. '_'
  5. 'あ'

A backslash denotes a special character, which can either be a named escape sequence or a numerical representation of a unicode codepoint.

Available escape sequences:

  1. '\'' # single quote
  2. '\\' # backslash
  3. '\a' # alert
  4. '\b' # backspace
  5. '\e' # escape
  6. '\f' # form feed
  7. '\n' # newline
  8. '\r' # carriage return
  9. '\t' # tab
  10. '\v' # vertical tab
  11. '\0' # null character
  12. '\uFFFF' # hexadecimal unicode character
  13. '\u{10FFFF}' # hexadecimal unicode character

A backslash followed by a u denotes a unicode codepoint. It can either be followed by exactly four hexadecimal characters representing the unicode bytes (\u0000 to \uFFFF) or a number of one to six hexadecimal characters wrapped in curly braces (\u{0} to \u{10FFFF}.

  1. '\u0041' # => 'A'
  2. '\u{41}' # => 'A'
  3. '\u{1F52E}' # => '🔮'