So I started to learn Lua(5.1) and I saw that thing called literal strings. And I have no idea what these do. The manual says \a is a bell but when I type
print('hello\athere')
The IDE prints a weird square with 'bel' written on it. So if someone could help me and explain every one of them[Literal Strings]. that would be really helpful.
p.s. i use Sublime Text 3
Only ASCII between 0x20
and 0x7E
are printable characters. How other characters are output, including '\a'
and '\b'
, is up to the implementation.
'\a'
, the ASCII 7
for BEL
, is designed to be used to alert. Typical terminal would make an audible or visible alert when outputing '\a'
. Your IDE choose to show a different output other than an alert. That's OK since it's up to the implementation.
Such sequences are called "escape sequences", and are found in many different languages. They are used to encode non-printable characters such as newlines in literal (hardcoded) strings.
Lua supports the following escape sequences:
\a
: Bell\b
: Backspace\f
: Form feed\n
: Newline\r
: Carriage return\t
: Tab\v
: Vertical tab\\
: Backslash\"
: Double quote\'
: Single quote\nnn
: Octal value (nnn
is 3 octal digits)\xNN
: Hex value (Lua5.2/LuaJIT, NN
is two hex digits)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With