Module:Unichar
Revision as of 04:58, 29 June 2018 by blackwiki>Erutuon (rudimentary Template:Unichar-ish function)
Tests
- Lua error at line 14: hexadecimal number expected, got 'a9'.
- Lua error at line 16: bad argument #3 to 'format' (number expected, got string).
- Lua error at line 14: hexadecimal number expected, got 'ac00'.
local p = {}
local function errorf(level, ...)
if type(level) == number then
return error(string.format(...), level + 1)
else -- level is actually the format string.
return error(string.format(level, ...), 2)
end
end
function p.unichar(frame)
local codepoint = frame.args[1]
codepoint = tonumber(codepoint)
or errorf("hexadecimal number expected, got '%s'", codepoint)
return ("U+%04X %#x%X; %s"):format(codepoint, codepoint,
require "Module:Unicode data".lookup_name(codepoint))
end
return p