Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Cultopedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Ko-utils
Module
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
local p = {} local find = mw.ustring.find local hanja_ranges = "[〇㐀-䶿一-鿿﨎﨏﨑﨓﨔﨟﨡﨣﨤﨧-﨩𠀀-𪛟𪜀-𰀀-𲎯]" -- Iteratively applies gsub text replacements to a given piece of text -- table should contain pairs of search patterns and replacements function p.gsub_iterate(text, table) for _, entry in ipairs(table) do text = mw.ustring.gsub(text, entry[1], entry[2]) end return text end -- Decomposes Hangul into jamo (e.g. 한 (U+D55C) → ᄒ (U+1112), ᅡ (U+1161), ᆫ (U+11AB)) function p.decompose_hangul(text) return mw.ustring.gsub(text, "[가-힣]", mw.ustring.toNFD) end -- Returns boolean on whether input contains any Hangul text at all function p.contains_hangul(text) local hangul_ranges = "[ᄀ-ᇿ〮〯ㄱ-ㆎ㈀-㈞㉠-㉾ꥠ-가-힣ힰ-]" return text ~= nil and text ~= "" and find(text, hangul_ranges) end -- Returns boolean on whether input Hangul contains any special chars used by Module:Ko-translit function p.hangul_contains_syntax(text) -- check if string empty if text == nil or text == "" then return false end -- check if first char of string is a special char if mw.ustring.match(mw.ustring.sub(text, 1, 1), "[%$%%%*@%^_`]") then return true end -- check if the rest of the chars are special return find(text, "[^\\][%$%%%*@%^_`]") end -- Returns boolean on whether input contains any Hanja text at all function p.contains_hanja(text) return text ~= nil and text ~= "" and find(text, hanja_ranges) end -- Returns boolean on whether input only contains Hanja text function p.all_hanja(text) for i = 1, #text do local c = text:sub(i, i) if not find(c, hanja_ranges) then return false end end return true end -- Returns boolean on whether input directly contains a Wikipedia reference function p.contains_reference(text) return find(text, "'\"`UNIQ--") or find(text, "-QINU`\"'") end return p
Summary:
Please note that all contributions to Cultopedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Cultopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Ko-utils/doc
(
edit
)
Search
Search
Editing
Module:Ko-utils
Add topic