Lua中如何将字符编码转换为字符串字符?
例如
d = 48
-- this is what I want
str_d = "0"
Run Code Online (Sandbox Code Playgroud)
小智 5
您正在寻找string.char:
\n\n\nRun Code Online (Sandbox Code Playgroud)\n\nstring.char (\xc2\xb7\xc2\xb7\xc2\xb7)\n接收零个或多个整数。返回一个长度等于参数数量的字符串,其中每个字符的内部数字代码等于其对应的参数。
\n\n请注意,数字代码不一定可以跨平台移植。
\n
对于你的例子:
\n\nlocal d = 48\nlocal str_d = string.char(d) -- str_d == "0"\nRun Code Online (Sandbox Code Playgroud)\n