local socket = require "socket"
local function utf8len(ch)
if not ch then
return -1
end
if ch < 0x80 then
return 1
elseif ch < 0xC0 then
return -1
elseif ch < 0xE0 then
return 2
elseif ch < 0xF0 then
return 3
elseif ch < 0xF8 then
return 4
elseif ch < 0xFC then
return 5
elseif ch < 0xFE then
return 6
else
return -1
end
end
local function getutf8tbl(input)
if not input then
return nil, nil
end
local tbl = {}
local tbllen = {}
local len = #input
local i = 1
while i <= len do
local j = utf8len(string.byte(string.sub(input, i, i)))
if j <= 0 or i + j - 1 > len then
return nil, nil
end
table.insert(tbl, string.sub(input, i, i + j - 1))
table.insert(tbllen, j)
i = i + j
end
return tbl, tbllen
end
local f0 = socket.gettime()
local data = {}
local maxlen = 0
local firstword = {}
for line in io.lines(
lua之屏蔽字替换为 '*'
最新推荐文章于 2023-03-26 20:35:10 发布