<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Astring%2FdecodeEntities</id>
	<title>Module:string/decodeEntities - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Astring%2FdecodeEntities"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:string/decodeEntities&amp;action=history"/>
	<updated>2026-04-21T21:30:10Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:string/decodeEntities&amp;diff=494882&amp;oldid=prev</id>
		<title>Sware: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:string/decodeEntities&amp;diff=494882&amp;oldid=prev"/>
		<updated>2026-04-21T11:22:50Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:22, 21 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:string/decodeEntities&amp;diff=494881&amp;oldid=prev</id>
		<title>wikt&gt;Theknightwho: Protected &quot;Module:string/decodeEntities&quot;: Highly visible template/module ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:string/decodeEntities&amp;diff=494881&amp;oldid=prev"/>
		<updated>2025-05-21T14:24:27Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/wiki/Module:string/decodeEntities&quot; title=&quot;Module:string/decodeEntities&quot;&gt;Module:string/decodeEntities&lt;/a&gt;&amp;quot;: Highly visible template/module ([Edit=Allow only template editors and administrators] (indefinite) [Move=Allow only template editors and administrators] (indefinite))&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local load_module = &amp;quot;Module:load&amp;quot;&lt;br /&gt;
local string_char_module = &amp;quot;Module:string/char&amp;quot;&lt;br /&gt;
&lt;br /&gt;
local find = string.find&lt;br /&gt;
local gsub = string.gsub&lt;br /&gt;
local match = string.match&lt;br /&gt;
local require = require&lt;br /&gt;
local tonumber = tonumber&lt;br /&gt;
&lt;br /&gt;
local function u(...)&lt;br /&gt;
	u = require(string_char_module)&lt;br /&gt;
	return u(...)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local entities&lt;br /&gt;
local function get_entities()&lt;br /&gt;
	entities, get_entities = require(load_module).load_data(&amp;quot;Module:data/entities&amp;quot;), nil&lt;br /&gt;
	return entities&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function decode_entity(hash, x, code)&lt;br /&gt;
	-- &amp;quot;#&amp;quot; isn&amp;#039;t included in &amp;quot;[%w\128-\255]&amp;quot;, so if no &amp;quot;#&amp;quot; is found then it&amp;#039;s a&lt;br /&gt;
	-- a named entity or a false match.&lt;br /&gt;
	if hash == &amp;quot;&amp;quot; then&lt;br /&gt;
		return (entities or get_entities())[x .. code]&lt;br /&gt;
	end&lt;br /&gt;
	-- Exclude numbers that don&amp;#039;t fit the expected format.&lt;br /&gt;
	local cp&lt;br /&gt;
	if x == &amp;quot;&amp;quot; then&lt;br /&gt;
		cp = match(code, &amp;quot;^()%d+$&amp;quot;) and tonumber(code)&lt;br /&gt;
	else&lt;br /&gt;
		cp = match(code, &amp;quot;^()%x+$&amp;quot;) and tonumber(code, 16)&lt;br /&gt;
	end&lt;br /&gt;
	-- Exclude surrogates (U+D800 to U+DFFF) and codepoints that are too high.&lt;br /&gt;
	return cp and (&lt;br /&gt;
		cp &amp;lt;= 0xD7FF or&lt;br /&gt;
		cp &amp;gt;= 0xE000 and cp &amp;lt;= 0x10FFFF&lt;br /&gt;
	) and u(cp) or nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return function(str)&lt;br /&gt;
	-- As an optimisation, only do a full search with gsub() if plain searches&lt;br /&gt;
	-- for &amp;quot;&amp;amp;&amp;quot; and &amp;quot;;&amp;quot; find anything.&lt;br /&gt;
	local amp = find(str, &amp;quot;&amp;amp;&amp;quot;, nil, true)&lt;br /&gt;
	-- Search for &amp;quot;;&amp;quot; after the point &amp;quot;&amp;amp;&amp;quot; was found.&lt;br /&gt;
	return amp and find(str, &amp;quot;;&amp;quot;, amp + 1, true) and&lt;br /&gt;
		-- Non-ASCII characters aren&amp;#039;t valid in proper HTML named entities, but&lt;br /&gt;
		-- MediaWiki uses them in some nonstandard aliases (which have also been&lt;br /&gt;
		-- included in [[Module:data/entities]]), so include them anyway.&lt;br /&gt;
		gsub(str, &amp;quot;&amp;amp;(#?)([xX]?)([%w\128-\255]+);&amp;quot;, decode_entity) or&lt;br /&gt;
		str&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>wikt&gt;Theknightwho</name></author>
	</entry>
</feed>