03Values and kinds
Characters
Single characters in single quotes, and escape sequences.
A character is one letter, digit, sign or mark, written in single quotes: 'က',
'A', '?'. Its kind is စာလုံး ("letter"). All Unicode characters work, emoji
included.
စံကား
Expected output
က
A
春
🔥
A character literal holds one character, no more and no less. 'ab' is an error.
Escape sequences
Some characters are hard to enter, or have a special meaning inside quotes. These are written as an escape sequence. Escape sequences work in characters and in text.
စံကား
Expected output
'
က
တစ်
နှစ်
{ }
| Escape | Means |
|---|---|
{နောက်တစ်ကြောင်း} or \n | line break ("next line") |
\t | tab |
\r | carriage return |
\0 | the null character |
\\ | a backslash \ |
\' | a single quote ' |
\" | a double quote " |
{{ and }} | a brace { or } |
{ယူနီကုဒ် HHHH} or \uHHHH | the character with Unicode number HHHH (4 or 8 hex digits) |
A brace starts a Burmese escape name, so a single { or } must be doubled. A name
that Zaka does not know is an error:
စံကားZK0106
Expected error
error[ZK0106]: unknown escape sequence "{မသိ}"
Hands on
- Print the character with Unicode number
1015. - Print one piece of text that comes out on three lines.
Next: True and false.