<?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%3Ascripts%2FcharToScript</id>
	<title>Module:scripts/charToScript - 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%3Ascripts%2FcharToScript"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:scripts/charToScript&amp;action=history"/>
	<updated>2026-04-04T00:26:48Z</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:scripts/charToScript&amp;diff=423789&amp;oldid=prev</id>
		<title>Sware at 13:05, 11 January 2025</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:scripts/charToScript&amp;diff=423789&amp;oldid=prev"/>
		<updated>2025-01-11T13:05:20Z</updated>

		<summary type="html">&lt;p&gt;&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 13:05, 11 January 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local subexport = {}&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local subexport = {}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m_str_utils &lt;/del&gt;= require(&quot;Module:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;string utilities&lt;/del&gt;&quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require_when_needed &lt;/ins&gt;= require(&quot;Module:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require when needed&lt;/ins&gt;&quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local cp = &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m_str_utils.&lt;/del&gt;codepoint&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local cp = &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require_when_needed(&quot;Module:string utilities&quot;, &quot;&lt;/ins&gt;codepoint&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local floor = math.floor&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local floor = math.floor&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local get_plaintext = require_when_needed(&quot;Module:utilities&quot;, &quot;get_plaintext&quot;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local get_script = require_when_needed(&quot;Module:scripts&quot;, &quot;getByCode&quot;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local insert = table.insert&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local insert = table.insert&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local ipairs = ipairs&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local min = math.min&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local min = math.min&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local pairs = pairs&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local setmetatable = setmetatable&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local sort = table.sort&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local sort = table.sort&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local split = &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;m_str_utils.&lt;/del&gt;split&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local split = &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require_when_needed(&quot;Module:string utilities&quot;, &quot;&lt;/ins&gt;split&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&quot;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local table_len = require_when_needed(&quot;Module:table&quot;, &quot;length&quot;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;local type = type&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Copied from [[Module:Unicode data]].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Copied from [[Module:Unicode data]].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local function binaryRangeSearch(codepoint, ranges)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;local function binaryRangeSearch(codepoint, ranges)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local low, mid, high&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local low, mid, high&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	low, high = 1, ranges.length or &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require &quot;Module:table&quot;.length&lt;/del&gt;(ranges)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	low, high = 1, ranges.length or &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;table_len&lt;/ins&gt;(ranges)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	while low &amp;lt;= high do&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	while low &amp;lt;= high do&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		mid = floor((low + high) / 2)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		mid = floor((low + high) / 2)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l176&quot;&gt;Line 176:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 183:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local scripts = setmetatable({}, scripts_mt)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local scripts = setmetatable({}, scripts_mt)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	text = &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require(&quot;Module:utilities&quot;).&lt;/del&gt;get_plaintext(text)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	text = get_plaintext(text)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local combined_scripts = {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	local combined_scripts = {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l215&quot;&gt;Line 215:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 222:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	bestScript = bestScript or &amp;quot;None&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	bestScript = bestScript or &amp;quot;None&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	return &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;require(&quot;Module:scripts&quot;).getByCode&lt;/del&gt;(bestScript)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	return &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;get_script&lt;/ins&gt;(bestScript)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;end&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;end&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;return subexport&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;return subexport&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:scripts/charToScript&amp;diff=374689&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;local subexport = {}  local m_str_utils = require(&quot;Module:string utilities&quot;)  local cp = m_str_utils.codepoint local floor = math.floor local insert = table.insert local min = math.min local sort = table.sort local split = m_str_utils.split  -- Copied from Module:Unicode data. local function binaryRangeSearch(codepoint, ranges) 	local low, mid, high 	low, high = 1, ranges.length or require &quot;Module:table&quot;.length(ranges) 	while low &lt;= high do 		mid = floor((low + high)...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:scripts/charToScript&amp;diff=374689&amp;oldid=prev"/>
		<updated>2024-08-06T10:27:02Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;local subexport = {}  local m_str_utils = require(&amp;quot;Module:string utilities&amp;quot;)  local cp = m_str_utils.codepoint local floor = math.floor local insert = table.insert local min = math.min local sort = table.sort local split = m_str_utils.split  -- Copied from &lt;a href=&quot;/wiki/Module:Unicode_data&quot; title=&quot;Module:Unicode data&quot;&gt;Module:Unicode data&lt;/a&gt;. local function binaryRangeSearch(codepoint, ranges) 	local low, mid, high 	low, high = 1, ranges.length or require &amp;quot;Module:table&amp;quot;.length(ranges) 	while low &amp;lt;= high do 		mid = floor((low + high)...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local subexport = {}&lt;br /&gt;
&lt;br /&gt;
local m_str_utils = require(&amp;quot;Module:string utilities&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local cp = m_str_utils.codepoint&lt;br /&gt;
local floor = math.floor&lt;br /&gt;
local insert = table.insert&lt;br /&gt;
local min = math.min&lt;br /&gt;
local sort = table.sort&lt;br /&gt;
local split = m_str_utils.split&lt;br /&gt;
&lt;br /&gt;
-- Copied from [[Module:Unicode data]].&lt;br /&gt;
local function binaryRangeSearch(codepoint, ranges)&lt;br /&gt;
	local low, mid, high&lt;br /&gt;
	low, high = 1, ranges.length or require &amp;quot;Module:table&amp;quot;.length(ranges)&lt;br /&gt;
	while low &amp;lt;= high do&lt;br /&gt;
		mid = floor((low + high) / 2)&lt;br /&gt;
		local range = ranges[mid]&lt;br /&gt;
		if codepoint &amp;lt; range[1] then&lt;br /&gt;
			high = mid - 1&lt;br /&gt;
		elseif codepoint &amp;lt;= range[2] then&lt;br /&gt;
			return range, mid&lt;br /&gt;
		else&lt;br /&gt;
			low = mid + 1&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil, mid&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Copied from [[Module:Unicode data]].&lt;br /&gt;
local function linearRangeSearch(codepoint, ranges)&lt;br /&gt;
	for i, range in ipairs(ranges) do&lt;br /&gt;
		if codepoint &amp;lt; range[1] then&lt;br /&gt;
			break&lt;br /&gt;
		elseif codepoint &amp;lt;= range[2] then&lt;br /&gt;
			return range&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function compareRanges(range1, range2)&lt;br /&gt;
	return range1[1] &amp;lt; range2[1]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Save previously used codepoint ranges in case another character is in the&lt;br /&gt;
-- same range.&lt;br /&gt;
local rangesCache = {}&lt;br /&gt;
&lt;br /&gt;
--[=[&lt;br /&gt;
	Takes a codepoint or a character and finds the script code(s) (if any) that are appropriate for it based on the codepoint, using the data module [[Module:scripts/recognition data]]. The data module was generated from the patterns in [[Module:scripts/data]] using [[Module:User:Erutuon/script recognition]].&lt;br /&gt;
	&lt;br /&gt;
	By default, it returns only the first script code if there are multiple matches (i.e. the code we take to be the default). If `all_scripts` is set, then a table of all matching codes is returned.&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local charToScriptData&lt;br /&gt;
function subexport.charToScript(char, all_scripts)&lt;br /&gt;
	charToScriptData = charToScriptData or mw.loadData(&amp;quot;Module:scripts/recognition data&amp;quot;)&lt;br /&gt;
	local t = type(char)&lt;br /&gt;
	local codepoint&lt;br /&gt;
	if t == &amp;quot;string&amp;quot; then&lt;br /&gt;
		local etc&lt;br /&gt;
		codepoint, etc = cp(char, 1, 2)&lt;br /&gt;
		if etc then&lt;br /&gt;
			error(&amp;quot;bad argument #1 to &amp;#039;charToScript&amp;#039; (expected a single character)&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	elseif t == &amp;quot;number&amp;quot; then&lt;br /&gt;
		codepoint = char&lt;br /&gt;
	else&lt;br /&gt;
		error((&amp;quot;bad argument #1 to &amp;#039;charToScript&amp;#039; (expected string or a number, got %s)&amp;quot;)&lt;br /&gt;
			:format(t))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local ret = {}&lt;br /&gt;
	local individualMatch = charToScriptData.individual[codepoint]&lt;br /&gt;
	if individualMatch then&lt;br /&gt;
		ret = split(individualMatch, &amp;quot;%s*,%s*&amp;quot;, true)&lt;br /&gt;
	else&lt;br /&gt;
		local range&lt;br /&gt;
		if rangesCache[1] then&lt;br /&gt;
			range = linearRangeSearch(codepoint, rangesCache)&lt;br /&gt;
			if range then&lt;br /&gt;
				for i, script in ipairs(range) do&lt;br /&gt;
					if i &amp;gt; 2 then&lt;br /&gt;
						insert(ret, script)&lt;br /&gt;
						if not all_scripts then&lt;br /&gt;
							break&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		if not ret[1] then&lt;br /&gt;
			local index = floor(codepoint / 0x1000)&lt;br /&gt;
			range = linearRangeSearch(index, charToScriptData.blocks)&lt;br /&gt;
			if not range and charToScriptData[index] then&lt;br /&gt;
				range = binaryRangeSearch(codepoint, charToScriptData[index])&lt;br /&gt;
				if range then&lt;br /&gt;
					insert(rangesCache, range)&lt;br /&gt;
					sort(rangesCache, compareRanges)&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
			if range then&lt;br /&gt;
				for i, script in ipairs(range) do&lt;br /&gt;
					if i &amp;gt; 2 then&lt;br /&gt;
						insert(ret, script)&lt;br /&gt;
						if not all_scripts then&lt;br /&gt;
							break&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	if not ret[1] then&lt;br /&gt;
		insert(ret, &amp;quot;None&amp;quot;)&lt;br /&gt;
	end&lt;br /&gt;
	if all_scripts then&lt;br /&gt;
		return ret&lt;br /&gt;
	else&lt;br /&gt;
		return ret[1]&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[=[&lt;br /&gt;
	Finds the best script for a string in a language-agnostic way.&lt;br /&gt;
	&lt;br /&gt;
	Converts each character to a codepoint. Iterates the counter for the script code if the codepoint is in the list&lt;br /&gt;
	of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to.&lt;br /&gt;
	&lt;br /&gt;
	Each script has a two-part counter, for primary and secondary matches. Primary matches are when the script is the&lt;br /&gt;
	first one listed; otherwise, it&amp;#039;s a secondary match. When comparing scripts, first the total of both are compared&lt;br /&gt;
	(i.e. the overall number of matches). If these are the same, the number of primary and then secondary matches are&lt;br /&gt;
	used as tiebreakers. For example, this is used to ensure that `Grek` takes priority over `Polyt` if no characters&lt;br /&gt;
	which exclusively match `Polyt` are found, as `Grek` is a subset of `Polyt`.&lt;br /&gt;
	&lt;br /&gt;
	If `none_is_last_resort_only` is specified, this will never return None if any characters in `text` belong to a&lt;br /&gt;
	script. Otherwise, it will return None if there are more characters that don&amp;#039;t belong to a script than belong to&lt;br /&gt;
	any individual script. (FIXME: This behavior is probably wrong, and `none_is_last_resort_only` should probably&lt;br /&gt;
	become the default.)&lt;br /&gt;
]=]&lt;br /&gt;
function subexport.findBestScriptWithoutLang(text, none_is_last_resort_only)&lt;br /&gt;
	-- `scripts` contains counters for any scripts detected so far. Jpan and Kore are handled as special-cases, as they are combinations of other scripts.&lt;br /&gt;
	local scripts_mt = 	{Jpan = true, Kore = true}&lt;br /&gt;
	&lt;br /&gt;
	local weights_mt = {&lt;br /&gt;
		__lt = function(a, b)&lt;br /&gt;
			if a[1] + a[2] ~= b[1] + b[2] then&lt;br /&gt;
				return a[1] + a[2] &amp;lt; b[1] + b[2]&lt;br /&gt;
			elseif a[1] ~= b[1] then&lt;br /&gt;
				return a[1] &amp;lt; b[1]&lt;br /&gt;
			elseif a[2] ~= b[2] then&lt;br /&gt;
				return a[2] &amp;lt; b[2]&lt;br /&gt;
			else&lt;br /&gt;
				return false&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	}&lt;br /&gt;
	scripts_mt.__index = function(t, k)&lt;br /&gt;
		local ret = {}&lt;br /&gt;
		if k == &amp;quot;Jpan&amp;quot; and scripts_mt.Jpan then&lt;br /&gt;
			for i = 1, 2 do&lt;br /&gt;
				ret[i] = t[&amp;quot;Hani&amp;quot;][i] + t[&amp;quot;Hira&amp;quot;][i] + t[&amp;quot;Kana&amp;quot;][i]&lt;br /&gt;
			end&lt;br /&gt;
		elseif k == &amp;quot;Kore&amp;quot; and scripts_mt.Kore then&lt;br /&gt;
			for i = 1, 2 do&lt;br /&gt;
				ret[i] = t[&amp;quot;Hani&amp;quot;][i] + t[&amp;quot;Hang&amp;quot;][i]&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			for i = 1, 2 do&lt;br /&gt;
				insert(ret, 0)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		return setmetatable(ret, weights_mt)&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local scripts = setmetatable({}, scripts_mt)&lt;br /&gt;
	&lt;br /&gt;
	text = require(&amp;quot;Module:utilities&amp;quot;).get_plaintext(text)&lt;br /&gt;
	&lt;br /&gt;
	local combined_scripts = {&lt;br /&gt;
		Jpan = {[&amp;quot;Hani&amp;quot;] = true, [&amp;quot;Hira&amp;quot;] = true, [&amp;quot;Kana&amp;quot;] = true},&lt;br /&gt;
		Kore = {[&amp;quot;Hani&amp;quot;] = true, [&amp;quot;Hang&amp;quot;] = true}&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	for character in text:gmatch(&amp;quot;.[\128-\191]*&amp;quot;) do&lt;br /&gt;
		for i, script in ipairs(subexport.charToScript(character, true)) do&lt;br /&gt;
			if not none_is_last_resort_only or script ~= &amp;quot;None&amp;quot; then&lt;br /&gt;
				scripts[script] = scripts[script]&lt;br /&gt;
				local weight = min(i, 2)&lt;br /&gt;
				scripts[script][weight] = scripts[script][weight] + 1&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- Check the combined script counts. If a single constituent has the same count (i.e. it&amp;#039;s the only one), discard the combined script.&lt;br /&gt;
	for combined_script, set in pairs(combined_scripts) do&lt;br /&gt;
		for script in pairs(set) do&lt;br /&gt;
			scripts[combined_script] = scripts[combined_script]&lt;br /&gt;
			if (scripts[script][1] + scripts[script][2]) == (scripts[combined_script][1] + scripts[combined_script][2]) then&lt;br /&gt;
				scripts[combined_script] = nil&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local bestScript&lt;br /&gt;
	local greatestCount&lt;br /&gt;
	for script, count in pairs(scripts) do&lt;br /&gt;
		if (not greatestCount) or greatestCount &amp;lt; count then&lt;br /&gt;
			bestScript = script&lt;br /&gt;
			greatestCount = count&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	bestScript = bestScript or &amp;quot;None&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	return require(&amp;quot;Module:scripts&amp;quot;).getByCode(bestScript)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return subexport&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>