local p =
local Unicode_data = require "Module:Unicode data"
local function errorf(level, ...) if type(level)
-- from local styles = local function style(text, type) if not styles[type] then errorf("Style %s not recognized", type) end return ('
%s'):format(styles[type], text)endlocal U = mw.ustring.charlocal function show(codepoint) -- Format characters that at least are visible to me. -- The parentheses will short-circuit the evaluation of some of the conditions. -- Arabic number sign, Arabic sign sanah, Arabic footnote marker, Arabic sign safha, Arabic sign samvat if 0x600 <= codepoint and (codepoint <= 0x604 -- Arabic end of ayah, Syriac abbreviation mark, Arabic disputed end of ayah or codepoint
0x70F or codepoint
local function u_plus(codepoint) return ("U+%04X"):format(codepoint)end
local function get_codepoint(args, arg) local val = args[arg] local is_negative = false if type(val) ~= "string" then errorf("code point in hexadecimal expected, got %s", type(val)) elseif val:find('^%s*%-') then -- Negative number strings yield a bizarre value: -- tonumber("-1", 16) -> 1.844674407371e+19. -- Strip initial minus. val = val:match("%-(.+)") is_negative = true end local codepoint = tonumber(val, 16) or errorf("code point in hexadecimal expected, got %q", val) if is_negative then codepoint = -codepoint end if not (0 <= codepoint and codepoint <= 0x10FFFF) then errorf("code point %d out of range", codepoint) end return codepointend
function p.unichar(frame) local args = frame.args[1] and frame.args or frame:getParent.args local codepoint = get_codepoint(args, 1) local name_or_label = Unicode_data.lookup_name(codepoint) local is_label = name_or_label:sub(1, 1)
return p