Hello, so if you are confused by the Topic Title, I am wondering wondering what exactly are the number codes for the functions like utf8.char() and string.char() where they give you a specific character from the number given, like such:
local random = math.random(65, 90) -- random number
-- random character?
string.char(random) -- 'string'
utf8.char(random) -- 'utf8'
I’m not sure if they are already listed or if I’m missing something but I want to know what exactly they mean so I can use it properly.
string.byte will only return the first byte so in the case of multi-byte characters (i.e. arbitrary input or non-English languages) use the utf8 library, not string.
print(utf8.codepoint('h')) --> 104
print(utf8.char(104)) --> h
print(string.byte('h')) --> 104
print(string.char(104)) --> h
-----
print(utf8.codepoint('象')) --> 35937, ok
print(utf8.char(35937)) --> 象, ok
print(string.byte('象')) --> 232, control character (first byte of 象)
print(string.char(35937)) --> error