本文最后更新于 412 天前,其中的信息可能已经有所发展或是发生改变。
function GetStringLen(pzStr)
local result = 0
for i=1,#pzStr do
local curByte = string.byte(pzStr, i)
local byteCount = 1;
if curByte>0 and curByte<=127 then
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
result = result + byteCount
end
return result
end