Module:Kangxi radical explained

require('strict')

local p =

function p.find(t, srch) -- search by value for k, _ in ipairs(t) do if t[k]

srch then return k; end endend

local labels =

local variants =

function p.Kxr(frame) local getArgs = require('Module:Arguments').getArgs return p._Kxr(getArgs(frame))end

local function utfEscape(hex) return "&#" .. hex .. ";"end

function p.toRadicalNumber(ch) local codepoint = mw.ustring.codepoint(ch) local result = nil

if codepoint >= 0x2F00 and codepoint <= 0x2FD5 then result = codepoint - 0x2F00 + 1 else result = variants[ch] end

if not result then result = p.find(labels, ch); end return resultend

function p._Kxr(args) local num = nil local add_link = false local add_label = args["name"] ~= "no" local add_numero = false local use_variant = false

local glyph = "" local label = "" local result = ""

if tonumber(args[1]) then num = math.floor(tonumber(args[1])) else num = p.toRadicalNumber(string.lower(args[1])) if args["variant"] or args["v"] then use_variant = true; end end local unicode = 0x2F00 + num - 1

if use_variant and mw.ustring.len(args[1])

1 then glyph = args[1] else glyph = utfEscape(unicode); end

if args["l"] or args["link"] or args["links"] then add_link = true; end

if add_label then local label_style = "\"font-variant:all-small-caps\"" label = string.upper(labels[num])

if add_link then label = "".. label .. ""; end label = "&emsp13;

'" .. label .. "'" end

result = "

" .. glyph .. "" .. label return resultend

return p