local tb = {}
local lenInByte = #str
local i = 1
while 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