-- \t tab, \n new line, \r carriage return,
-- \" or \' quote, \\ backslash
local escaped = "She said \"Hello!\" to me."
-- escaped = She said "Hello!" to me.
-- Other quotes: no escape needed
local other_quotes = 'She said "Hello!" to me.'
-- other_quotes = She said "Hello!" to me.
local apostrophe = "It's fine"
-- apostrophe = It's fine
-- By code: \x hex, \u{} Unicode, \ddd decimal
local letters = {"\x41", "\u{41}", "\065"}
-- letters = A, A, A
-- In [[ ]] a backslash stays as it is
local path = [[C:\Temp\new]]
-- path = C:\Temp\new
-- %q gives a quoted text that Lua reads back
local quoted = string.format("%q", escaped)
-- quoted = "She said \"Hello!\" to me."
-- An unknown escape is an error at compile time
local chunk, err = load([[return "\d"]])
-- chunk = nil
-- err = [string "return "\d""]:1: invalid
-- escape sequence near '"\d'
print("escaped = " .. escaped)
print("other_quotes = " .. other_quotes)
print("apostrophe = " .. apostrophe)
print("letters = " .. table.concat(letters, ", "))
print("path = " .. path)
print("quoted = " .. quoted)
print("chunk = " .. tostring(chunk))
print("err = " .. err)