Module:Character info explained

local m_unicode = require('Module:Unicode data')local char_to_script = require('Module:scripts').charToScript

local export =

local dingbat_scripts =

local function page_exists(title) local ok, title_obj = pcall(mw.title.new, title) if ok and title_obj then local ok, exists = pcall(function return title_obj.exists end) return ok and exists else return false endend

function export.exotic_symbol_warning(frame) local title = mw.title.getCurrentTitle if title.exists then return "" end if mw.ustring.len(title.fullText) ~= 1 then return "" end local codepoint = mw.ustring.codepoint(title.fullText) local script_code = char_to_script(codepoint)

if dingbat_scripts[script_code] then return frame:expandTemplate end

return ""end

local function get_codepoint(codepoint, param_name) if codepoint then codepoint = mw.text.trim(codepoint) codepoint = tonumber(codepoint) or mw.text.decode(codepoint) if (type(codepoint)

"string") and (mw.ustring.len(codepoint)

1) then codepoint = mw.ustring.codepoint(codepoint) elseif type(codepoint) ~= "number" then error("Unrecognised string given for the " .. param_name .. " parameter") end end return codepointend

function export._show(args, parent_title) local codepoint = args.codepoint or args[1] or ""; local image local title = mw.title.getCurrentTitle local to_boolean = require('Module:yesno') local namespace = mw.title.getCurrentTitle.nsText

if codepoint ~= "" then codepoint = get_codepoint(codepoint, "codepoint") else if title.fullText

parent_title then codepoint = 0xfffd elseif mw.ustring.len(title.fullText)

1 then codepoint = mw.ustring.codepoint(title.fullText) else if title.nsText

"Template" then return "" end error("Page title is not a single Unicode character") end end

args.image = args.image and mw.text.trim(args.image) if args.image

"" then image = nil else image = args.image or m_unicode.lookup_image(codepoint) end

local table_markup = table.insert(table_markup, '