Since Lua 3.1, you can use decimal escape sequences in liberal strings.
Starting with Lua 5.2, you can use hexadecimal escape sequences in string literals.
In Lua 5.1, you can convert hex escape posteriori files:
s=[[hello \x77\x6f\x72\x6c\x64]] s=s:gsub("\\x(%x%x)",function (x) return string.char(tonumber(x,16)) end) print(s)
Note the use of long strings that do not interpret escape sequences. If you use short strings (in quotation marks), as in your source code, then \x will silently convert to x , because Lua 5.1 does not understand \x . Lua 5.2 and later complain about escape sequences that it does not understand.
source share