Модуль:Character code
Дакументацыю да гэтага модуля можна стварыць у Модуль:Character code/Дакументацыя
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p._main(args)
end
function p._main(args)
local char = args[1]
local encoding = args[2] or 'unicode'
local representation = args[3] or 'decimal'
local code = {}
for codepoint in mw.ustring.gcodepoint(char) do
table.insert(code, codepoint)
end
local s = ''
if representation == 'decimal' then
if encoding == 'unicode' then
s = table.concat(code, ' ')
elseif encoding == 'numeric character reference' then
for i, v in ipairs(code) do
s = s .. '&#' .. v .. ';'
end
end
elseif representation == 'hex' then
for i, v in ipairs(code) do
if encoding == 'unicode' then
s = s .. 'U+' .. string.format('%X', v) .. ' '
elseif encoding == 'numeric character reference' then
s = s .. '&#x' .. string.format('%X', v) .. ';'
end
end
end
return mw.text.trim(s)
end
return p