Special characters

Basic types / Character type

-- \u{...}: a code point in hex, any length
local ruble = "\u{20BD}"
-- ruble = ₽
local lambda = "\u{3BB}"
-- lambda = λ

-- More than four digits: the same escape
local smile = "\u{1F600}"
-- smile is the grinning face

-- utf8.char takes the number itself
local same = utf8.char(0x1F600) == smile
-- same = true

-- The braces are required
local chunk, err = load([[return "\u20BD"]])
-- chunk = nil
-- err = [string "return "\u20BD""]:1: missing '{'
-- near '"\u2'

print("ruble = " .. ruble)
print("lambda = " .. lambda)
print("smile = " .. smile)
print("same = " .. tostring(same))
print("chunk = " .. tostring(chunk))
print("err = " .. err)