How can I convert a character code to a string character in Lua?
E.g.
d = 48
-- this is what I want
str_d = "0"
For ASCII characters, you can use string.char
.
For UTF-8 strings, you can use utf8.char
(introduced in Lua 5.3) to get a character from its code point.
print(utf8.char(48)) -- 0
print(utf8.char(29790)) -- 瑞
You are looking for
string.char
:For your example: