Module:Str2code:修订间差异
跳转到导航
跳转到搜索
无编辑摘要 |
无编辑摘要 |
||
第16行: | 第16行: | ||
local text = args[1] |
local text = args[1] |
||
return string.format("%d",p.str2code(text)) |
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 |
end |
||
2023年4月15日 (六) 00:49的版本
可在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