概述
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单个切割所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复