mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-26 09:13:53 +01:00
Updates via shellscript
This commit is contained in:
parent
c1514fc8fb
commit
4197e25f52
22
init.lua
22
init.lua
@ -414,13 +414,31 @@ string_ext={
|
|||||||
return (byte >= string_ext.zero and byte <= string_ext.nine) or (byte >= string_ext.letter_a and byte <= string_ext.letter_f)
|
return (byte >= string_ext.zero and byte <= string_ext.nine) or (byte >= string_ext.letter_a and byte <= string_ext.letter_f)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
magic_chars={"(", ")", ".", "%", "+", "-", "*", "?", "[", "^", "$"},
|
magic_chars={"%", "(", ")", ".", "+", "-", "*", "?", "[", "^", "$"},
|
||||||
|
|
||||||
escape_magic_chars=function(text)
|
escape_magic_chars=function(text)
|
||||||
for _, magic_char in pairs(string_ext.magic_chars) do
|
for _, magic_char in ipairs(string_ext.magic_chars) do
|
||||||
text=string.gsub(text, "%"..magic_char,"%%"..magic_char)
|
text=string.gsub(text, "%"..magic_char,"%%"..magic_char)
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
|
end,
|
||||||
|
|
||||||
|
utf8=function(number)
|
||||||
|
if number < 0x00A0 or number > 0x10FFFF then --Out of range
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local result=""
|
||||||
|
local i=0
|
||||||
|
while true do
|
||||||
|
local remainder=number % 64
|
||||||
|
result=string.char(128+remainder)..result
|
||||||
|
number=(number-remainder) / 64
|
||||||
|
i=i+1
|
||||||
|
if number <= math.pow(2, 8-i-2) then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return string.char(256-math.pow(2, 8-i-1)+number)..result --256 = math.pow(2, 8)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user