Jump to content

Module:Kangxi radical

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Remsense (talk | contribs) at 14:14, 11 October 2023. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

require('strict')

local p = {}

function p.Kxr(frame)
	-- simplify handling of args
	local getArgs = require('Module:Arguments').getArgs
	local args = getArgs(frame)
	local r = tonumber(args[1])
	if args[2] then
		error("Only one argument of a number between 1 and 214 is accepted")
	elseif r < 1 or r > 214 then
		error("Argument must be between 1 and 214")
	else
		return p._Kxr(r)
	end
	return
end

function p._Kxr(r)
	local unicode = math.floor(r) + 0x2F00 - 1
	local u_str = "&#" .. unicode .. ";"
	local result = u_str
	
	return result
end

return p