Add luacheck (#3)

Co-authored-by: syimyuzya <syimyuzya@gmail.com>
This commit is contained in:
OgelGames
2021-12-09 15:46:33 +11:00
committed by GitHub
parent 30d0af57be
commit aa5f865131
5 changed files with 49 additions and 29 deletions

View File

@ -237,7 +237,7 @@ local nmdc = {
[124] = "|"
}
function AnsiToUtf8(s)
function signs_lib.AnsiToUtf8(s)
local r, b = ""
for i = 1, s and s:len() or 0 do
b = s:byte(i)
@ -258,7 +258,7 @@ function AnsiToUtf8(s)
return r
end
function Utf8ToAnsi(s)
function signs_lib.Utf8ToAnsi(s)
local r, b = ""
local scope
local j, l, u
@ -278,7 +278,7 @@ function Utf8ToAnsi(s)
if scope[b] then
scope = scope[b]
if "string" == type(scope) then
r, scope = r .. scope
r, scope = r .. scope, nil
j = -1 -- supress general UTF-8 parser
end
else
@ -290,11 +290,11 @@ function Utf8ToAnsi(s)
-- general UTF-8 parser
if j == -1 then -- supressed by legacy parser
j, l, u = nil
j = nil
elseif b < 0x80 then
if j then
r = r .. "&#ufffd;"
j, l, u = nil
j = nil
end
-- ASCII handled by legacy parser
elseif b >= 0xc0 then
@ -304,7 +304,7 @@ function Utf8ToAnsi(s)
j = i
if b >= 0xf8 then
r = r .. "&#ufffd;"
j, l, u = nil
j = nil
elseif b >= 0xf0 then
l, u = 4, b % (2 ^ 3)
elseif b >= 0xe0 then
@ -317,7 +317,7 @@ function Utf8ToAnsi(s)
u = u * (2 ^ 6) + b % (2 ^ 6)
if i == j + l - 1 then
r = r .. string.format("&#u%x;", u)
j, l, u = nil
j = nil
end
else
r = r .. "&#ufffd;"