Module:Str2code
可在Module:Str2code/doc创建此模块的帮助文档
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.str2code(strin)
if(math.modf(string.byte(strin,1)/16)==14)then
return (string.byte(strin,1)-224)*4096+(string.byte(strin,2)-128)*64+(string.byte(strin,3)-128)
elseif(math.modf(string.byte(strin,1)/32)==6)then
return (string.byte(strin,1)-192)*64+(string.byte(strin,2)-128)
else
return string.byte(strin,1)
end
end
function p.string2code(frame)
local args = getArgs(frame)
local text = args[1]
return string.format("%d",p.str2code(text))
end
function p.string2xcode(frame)
local args = getArgs(frame)
local text = args[1]
return string.format("%x",p.str2code(text))
end
return p