<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.drugwiki.net/wen/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnicode_convert</id>
	<title>Module:Unicode convert - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.drugwiki.net/wen/index.php?action=history&amp;feed=atom&amp;title=Module%3AUnicode_convert"/>
	<link rel="alternate" type="text/html" href="https://www.drugwiki.net/wen/index.php?title=Module:Unicode_convert&amp;action=history"/>
	<updated>2026-11-06T09:16:43Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://www.drugwiki.net/wen/index.php?title=Module:Unicode_convert&amp;diff=10265&amp;oldid=prev</id>
		<title>Sysop: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.drugwiki.net/wen/index.php?title=Module:Unicode_convert&amp;diff=10265&amp;oldid=prev"/>
		<updated>2025-11-01T20:55:05Z</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;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:55, 1 November 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&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;!-- diff cache key drugwiki_drugwikien:diff:1.41:old-10264:rev-10265 --&gt;
&lt;/table&gt;</summary>
		<author><name>Sysop</name></author>
	</entry>
	<entry>
		<id>https://www.drugwiki.net/wen/index.php?title=Module:Unicode_convert&amp;diff=10264&amp;oldid=prev</id>
		<title>en&gt;GKFX: Add fromUTF8 function</title>
		<link rel="alternate" type="text/html" href="https://www.drugwiki.net/wen/index.php?title=Module:Unicode_convert&amp;diff=10264&amp;oldid=prev"/>
		<updated>2021-04-11T13:12:30Z</updated>

		<summary type="html">&lt;p&gt;Add fromUTF8 function&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;
-- NOTE: all these functions use frame solely for its args member.&lt;br /&gt;
-- Modules using them may therefore call them with a fake frame table&lt;br /&gt;
-- containing only args.&lt;br /&gt;
&lt;br /&gt;
p.getUTF8 = function (frame)&lt;br /&gt;
	local ch = mw.ustring.char(tonumber(frame.args[1] or &amp;#039;0&amp;#039;, 16) or 0)&lt;br /&gt;
	local bytes = {mw.ustring.byte(ch, 1, -1)}&lt;br /&gt;
	local format = ({&lt;br /&gt;
		[&amp;#039;10&amp;#039;] = &amp;#039;%d&amp;#039;,&lt;br /&gt;
		dec = &amp;#039;%d&amp;#039;&lt;br /&gt;
	})[frame.args[&amp;#039;base&amp;#039;]] or &amp;#039;%02X&amp;#039;&lt;br /&gt;
	for i = 1, #bytes do&lt;br /&gt;
		bytes[i] = format:format(bytes[i])&lt;br /&gt;
	end&lt;br /&gt;
	return table.concat(bytes, &amp;#039; &amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.getUTF16 = function (frame)&lt;br /&gt;
	local codepoint = tonumber(frame.args[1] or &amp;#039;0&amp;#039;, 16) or 0&lt;br /&gt;
	local format = ({ -- TODO reduce the number of options.&lt;br /&gt;
		[&amp;#039;10&amp;#039;] = &amp;#039;%d&amp;#039;,&lt;br /&gt;
		dec = &amp;#039;%d&amp;#039;&lt;br /&gt;
	})[frame.args[&amp;#039;base&amp;#039;]] or &amp;#039;%04X&amp;#039;&lt;br /&gt;
	if codepoint &amp;lt;= 0xFFFF then -- NB this also returns lone surrogate characters&lt;br /&gt;
		return format:format(codepoint)&lt;br /&gt;
	elseif codepoint &amp;gt; 0x10FFFF then -- There are no codepoints above this&lt;br /&gt;
		return &amp;#039;&amp;#039;&lt;br /&gt;
	end&lt;br /&gt;
	codepoint = codepoint - 0x10000&lt;br /&gt;
	bit32 = require(&amp;#039;bit32&amp;#039;)&lt;br /&gt;
	return (format .. &amp;#039; &amp;#039; .. format):format(&lt;br /&gt;
		bit32.rshift(codepoint, 10) + 0xD800,&lt;br /&gt;
		bit32.band(codepoint, 0x3FF) + 0xDC00)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.fromUTF8 = function(frame)&lt;br /&gt;
	local basein = frame.args[&amp;#039;basein&amp;#039;] == &amp;#039;dec&amp;#039; and 10 or 16&lt;br /&gt;
	local format = frame.args[&amp;#039;base&amp;#039;] == &amp;#039;dec&amp;#039; and &amp;#039;%d &amp;#039; or &amp;#039;%02X &amp;#039;&lt;br /&gt;
	local bytes = {}&lt;br /&gt;
	for byte in mw.text.gsplit(frame.args[1], &amp;#039;%s&amp;#039;) do&lt;br /&gt;
		table.insert(bytes, tonumber(byte, basein))&lt;br /&gt;
	end&lt;br /&gt;
	local chars = {mw.ustring.codepoint(string.char(unpack(bytes)), 1, -1)}&lt;br /&gt;
	return format:rep(#chars):sub(1, -2):format(unpack(chars))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>en&gt;GKFX</name></author>
	</entry>
</feed>