W3cubDocs

/Crystal

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.

'a'
'z'
'0'
'_'
'あ'

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:

'\''         # single quote
'\\'         # backslash
'\a'         # alert
'\b'         # backspace
'\e'         # escape
'\f'         # form feed
'\n'         # newline
'\r'         # carriage return
'\t'         # tab
'\v'         # vertical tab
'\uFFFF'     # hexadecimal unicode character
'\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}.

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

To the extent possible under law, the persons who contributed to this workhave waived
all copyright and related or neighboring rights to this workby associating CC0 with it.
https://crystal-lang.org/docs/syntax_and_semantics/literals/char.html