local tb = {}local lenInByte = #strlocal i = 1while i < (lenInByte + 1) do local curByte = string.byte(str, i) local szType local byteCount=1 if curByte>0 and curByte<=127 then if curByte>=48 and curByte<=57 then szType = ‘num‘ elseif (curByte>=97 and curByte<=122) or (curByte>=65 and curByte<=90) then szType = ‘letter‘ end byteCount = 1 elseif curByte>=192 and curByte<223 then byteCount = 2 elseif curByte>=224 and curByte<239 then byteCount = 3 elseif curByte>=240 and curByte<=247 then byteCount = 4 end local char = string.sub(str, i, i+byteCount-1) i = i + byteCount local item = {} if byteCount == 1 then item.type = szType and szType or "en" else item.type = "cn" end item.value = char table.insert(tb, item)end
时间: 2024-11-08 18:38:10