local function split(input)
local list = {}
local len = string.len(input)
local index = 1
while index <= len do
local c = string.byte(input, index)
local offset = 1
if c < 0xc0 then
offset = 1
elseif c < 0xe0 then
offset = 2
elseif c < 0xf0 then
offset = 3
elseif c < 0xf8 then
offset = 4
elseif c < 0xfc then
offset = 5
end
local str = string.sub(input, index, index+offset-1)
-- print(str)
index = index + offset
table.insert(list, {byteNum = offset, char = str})
end
return list
end
--utf8字符串分割为单个字符
function utf8StringSplit( str )
local strTable = {}
for uchar in string.gfind(str, "[%z1-127194-244][128-191]*") do
strTable[#strTable+1] = uchar
end
return strTable
end
最后
以上就是英俊手链最近收集整理的关于lua单个切割的全部内容,更多相关lua单个切割内容请搜索靠谱客的其他文章。
发表评论 取消回复