<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnichar</id>
	<title>Module:Unichar - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnichar"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Unichar&amp;action=history"/>
	<updated>2026-05-06T23:45:09Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Unichar&amp;diff=147417&amp;oldid=prev</id>
		<title>imported&gt;Erutuon: fix errorf</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Unichar&amp;diff=147417&amp;oldid=prev"/>
		<updated>2018-08-30T00:29:15Z</updated>

		<summary type="html">&lt;p&gt;fix errorf&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
local Unicode_data = require &amp;quot;Module:Unicode data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local function errorf(level, ...)&lt;br /&gt;
	if type(level) == &amp;quot;number&amp;quot; then&lt;br /&gt;
		return error(string.format(...), level + 1)&lt;br /&gt;
	else -- level is actually the format string.&lt;br /&gt;
		return error(string.format(level, ...), 2)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
 -- from [[Template:Unichar]]&lt;br /&gt;
local styles = {&lt;br /&gt;
	smallcaps = &amp;#039;class=&amp;quot;smallcaps&amp;quot; style=&amp;quot;font-variant: small-caps; font-size: smaller;&amp;quot;&amp;#039;,&lt;br /&gt;
	monospace = &amp;#039;style=&amp;quot;font-family: monospace, monospace;&amp;quot;&amp;#039;, -- why repeat it?&lt;br /&gt;
	background_color = &amp;#039;style=&amp;quot;background: lightblue;&amp;quot;&amp;#039;, -- for space characters&lt;br /&gt;
}&lt;br /&gt;
local function style(text, type)&lt;br /&gt;
	if not styles[type] then&lt;br /&gt;
		errorf(&amp;quot;Style %s not recognized&amp;quot;, type)&lt;br /&gt;
	end&lt;br /&gt;
	return (&amp;#039;&amp;lt;span %s&amp;gt;%s&amp;lt;/span&amp;gt;&amp;#039;):format(styles[type], text)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local U = mw.ustring.char&lt;br /&gt;
local function show(codepoint)&lt;br /&gt;
	-- Format characters that at least are visible to me.&lt;br /&gt;
	-- The parentheses will short-circuit the evaluation of some of the conditions.&lt;br /&gt;
	-- Arabic number sign, Arabic sign sanah, Arabic footnote marker, Arabic sign safha, Arabic sign samvat&lt;br /&gt;
	if 0x600 &amp;lt;= codepoint and (codepoint &amp;lt;= 0x604&lt;br /&gt;
			-- Arabic end of ayah, Syriac abbreviation mark, Arabic disputed end of ayah&lt;br /&gt;
			or codepoint == 0x6DD or codepoint == 0x70F or codepoint == 0x8E2&lt;br /&gt;
			-- interlinear annotation anchor, separator, terminator&lt;br /&gt;
			or 0xFFF9 &amp;lt;= codepoint and (codepoint &amp;lt;= 0xFFFB&lt;br /&gt;
			-- shorthand format letter overlap, continuing overlap, downstep&lt;br /&gt;
			or 0x1BCA0 &amp;lt;= codepoint and codepoint &amp;lt;= 0x1BCA3))&lt;br /&gt;
			or Unicode_data.is_printable(codepoint) then&lt;br /&gt;
		local printed_codepoint = U(codepoint)&lt;br /&gt;
		if mw.ustring.toNFC(printed_codepoint) ~= printed_codepoint then&lt;br /&gt;
			-- Prevent MediaWiki software from normalizing the character.&lt;br /&gt;
			printed_codepoint = (&amp;quot;&amp;amp;#x%X;&amp;quot;):format(codepoint)&lt;br /&gt;
		end&lt;br /&gt;
		if Unicode_data.is_combining(codepoint) then&lt;br /&gt;
			printed_codepoint = &amp;quot;◌&amp;quot; .. printed_codepoint&lt;br /&gt;
		end&lt;br /&gt;
		if Unicode_data.is_whitespace(codepoint) then&lt;br /&gt;
			printed_codepoint = style(printed_codepoint, &amp;quot;background_color&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
		return printed_codepoint&lt;br /&gt;
	else&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function u_plus(codepoint)&lt;br /&gt;
	return (&amp;quot;U+%04X&amp;quot;):format(codepoint)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_codepoint(args, arg)&lt;br /&gt;
	local val = args[arg]&lt;br /&gt;
	local is_negative = false&lt;br /&gt;
	&lt;br /&gt;
	if type(val) ~= &amp;quot;string&amp;quot; then&lt;br /&gt;
		errorf(&amp;quot;code point in [[hexadecimal]] expected, got %s&amp;quot;, type(val))&lt;br /&gt;
	elseif val:find(&amp;#039;^%s*%-&amp;#039;) then&lt;br /&gt;
		-- Negative number strings yield a bizarre value:&lt;br /&gt;
		-- tonumber(&amp;quot;-1&amp;quot;, 16) -&amp;gt; 1.844674407371e+19.&lt;br /&gt;
		-- Strip initial minus.&lt;br /&gt;
		val = val:match(&amp;quot;%-(.+)&amp;quot;)&lt;br /&gt;
		is_negative = true&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local codepoint = tonumber(val, 16)&lt;br /&gt;
		or errorf(&amp;quot;code point in [[hexadecimal]] expected, got %q&amp;quot;, val)&lt;br /&gt;
	&lt;br /&gt;
	if is_negative then&lt;br /&gt;
		codepoint = -codepoint&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if not (0 &amp;lt;= codepoint and codepoint &amp;lt;= 0x10FFFF) then&lt;br /&gt;
		errorf(&amp;quot;code point %d out of range&amp;quot;, codepoint)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	return codepoint&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.unichar(frame)&lt;br /&gt;
	local args = frame.args[1] and frame.args or frame:getParent().args&lt;br /&gt;
	local codepoint = get_codepoint(args, 1)&lt;br /&gt;
	&lt;br /&gt;
	local name_or_label = Unicode_data.lookup_name(codepoint)&lt;br /&gt;
	local is_label = name_or_label:sub(1, 1) == &amp;quot;&amp;lt;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	return (&amp;quot;%s %s %s&amp;quot;):format(&lt;br /&gt;
		style(u_plus(codepoint), &amp;quot;monospace&amp;quot;),&lt;br /&gt;
		show(codepoint),&lt;br /&gt;
		is_label and name_or_label or style(name_or_label, &amp;quot;smallcaps&amp;quot;))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Erutuon</name></author>
	</entry>
</feed>