-- 将字符串分割成字符数组
function splitStr2table(str)
local chars = {}
local pos = 1
while pos <= #str do
local firstByte = string.byte(str, pos)
if firstByte >= 0x81 and firstByte <= 0xFE then
-- 处理多字节字符(如中文)
table.insert(chars, string.sub(str, pos, pos + 1))
pos = pos + 2
else
-- 处理单字节字符
table.insert(chars, string.sub(str, pos, pos))
pos = pos + 1
end
end
return chars
end