<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AKo-utils</id>
	<title>Module:Ko-utils - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.cultopedia.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AKo-utils"/>
	<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Ko-utils&amp;action=history"/>
	<updated>2026-04-05T22:39:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.5</generator>
	<entry>
		<id>https://www.cultopedia.org/index.php?title=Module:Ko-utils&amp;diff=464&amp;oldid=prev</id>
		<title>imported&gt;Grapesurgeon: bug</title>
		<link rel="alternate" type="text/html" href="https://www.cultopedia.org/index.php?title=Module:Ko-utils&amp;diff=464&amp;oldid=prev"/>
		<updated>2026-01-06T04:16:01Z</updated>

		<summary type="html">&lt;p&gt;bug&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;
local find = mw.ustring.find&lt;br /&gt;
local hanja_ranges = &amp;quot;[〇㐀-䶿一-鿿﨎﨏﨑﨓﨔﨟﨡﨣﨤﨧-﨩𠀀-𪛟𪜀-𮹟𰀀-𲎯]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
-- Iteratively applies gsub text replacements to a given piece of text &lt;br /&gt;
-- table should contain pairs of search patterns and replacements&lt;br /&gt;
function p.gsub_iterate(text, table)&lt;br /&gt;
	for _, entry in ipairs(table) do&lt;br /&gt;
		text = mw.ustring.gsub(text, entry[1], entry[2])&lt;br /&gt;
	end&lt;br /&gt;
	return text&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Decomposes Hangul into jamo (e.g. 한 (U+D55C) → ᄒ (U+1112), ᅡ (U+1161), ᆫ (U+11AB))&lt;br /&gt;
function p.decompose_hangul(text)&lt;br /&gt;
	return mw.ustring.gsub(text, &amp;quot;[가-힣]&amp;quot;, mw.ustring.toNFD)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns boolean on whether input contains any Hangul text at all&lt;br /&gt;
function p.contains_hangul(text)&lt;br /&gt;
	local hangul_ranges = &amp;quot;[ᄀ-ᇿ〮〯ㄱ-ㆎ㈀-㈞㉠-㉾ꥠ-꥿가-힣ힰ-퟿]&amp;quot;&lt;br /&gt;
	return text ~= nil and text ~= &amp;quot;&amp;quot; and find(text, hangul_ranges)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns boolean on whether input Hangul contains any special chars used by Module:Ko-translit&lt;br /&gt;
function p.hangul_contains_syntax(text)&lt;br /&gt;
	-- check if string empty&lt;br /&gt;
	if text == nil or text == &amp;quot;&amp;quot; then&lt;br /&gt;
		return false&lt;br /&gt;
	end&lt;br /&gt;
	-- check if first char of string is a special char&lt;br /&gt;
	if mw.ustring.match(mw.ustring.sub(text, 1, 1), &amp;quot;[%$%%%*@%^_`]&amp;quot;) then&lt;br /&gt;
		return true&lt;br /&gt;
	end&lt;br /&gt;
	-- check if the rest of the chars are special&lt;br /&gt;
	return find(text, &amp;quot;[^\\][%$%%%*@%^_`]&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns boolean on whether input contains any Hanja text at all&lt;br /&gt;
function p.contains_hanja(text)&lt;br /&gt;
	return text ~= nil and text ~= &amp;quot;&amp;quot; and find(text, hanja_ranges)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns boolean on whether input only contains Hanja text&lt;br /&gt;
function p.all_hanja(text)&lt;br /&gt;
    for i = 1, #text do&lt;br /&gt;
        local c = text:sub(i, i)&lt;br /&gt;
        if not find(c, hanja_ranges) then&lt;br /&gt;
            return false&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Returns boolean on whether input directly contains a Wikipedia reference&lt;br /&gt;
function p.contains_reference(text)&lt;br /&gt;
	return find(text, &amp;quot;&amp;#039;\&amp;quot;`UNIQ--&amp;quot;) or find(text, &amp;quot;-QINU`\&amp;quot;&amp;#039;&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Grapesurgeon</name></author>
	</entry>
</feed>