字符串过滤,只保留中文,字母和数字
function ClientScene:filter_spec_chars(s)
local ss = {}
for k = 1, #s do
local c = string.byte(s,k)
if not c then break end
if (c>=48 and c= 65 and c=97 and c
table.insert(ss, string.char(c))
elseif c>=228 and c
local c1 = string.byte(s,k+1)
local c2 = string.byte(s,k+2)
if c1 and c2 then
local a1,a2,a3,a4 = 128,191,128,191
if c == 228 then a1 = 184
elseif c == 233 then a2,a4 = 190,c1 ~= 190 and 191 or 165
end
if c1>=a1 and c1=a3 and c2
k = k + 2
table.insert(ss, string.char(c,c1,c2))
end
end
end
end
return table.concat(ss)
end
领取专属 10元无门槛券
私享最新 技术干货