Escape sequences: special characters inside text
An escape sequence lets you write a character that would otherwise be hard to include in quoted text. In Pliro, it starts with a backslash: \. The following character tells Pliro what to put into the text value.
Why quotes need help
Quotes normally mark where text begins and ends. To include a quote in the message itself, use \":
# language: en
say "The turtle says: \"Hello!\""
say "First\nSecond"
say "A backslash: \\"
The first instruction prints the quotes around Hello!. The second prints two lines. The last prints one backslash.
| Write in the source | Character in the value |
|---|---|
\" |
A double quote |
\\ |
A backslash |
\n |
A newline |
\r |
A carriage return |
\t |
A tab |
These are Pliro’s supported escapes. An unknown sequence, such as backslash followed by q, produces an error. To include an emoji, type or paste the emoji directly; Pliro does not support \u escapes.
Source length and text length
"\n" contains two source characters between its quotes, but creates one code point in the text value. "\\n" instead creates a backslash followed by the letter n.
Predict length("\n") and length("\\n"). The answers are one and two.
