Jump to content
Menyu yikuru
Menyu yikuru
move to sidebar
kubisa
Mayendelo
Jani likulu
Vidumbizgano vya chikaya
Vakuchitika vasono
Kusintha kuphya
Jani lililose
Wovwili
To Do
Vyakuti vinozgeke
Vinyake
Mafumbo
Mazgo ghakomi
Helpful Pages (Wovwili)
Need for Fix
Need for Review
Admin Pages
Home pages
Home templates
Kufufuza
Kufufuza
Kaonekelo
Chakupeleka
Panga akaunti
Njila
Vilwelo vyako
Chakupeleka
Panga akaunti
Njila
Pages for logged out editors
learn more
vyakulemba
Pakuchezgela
Kulemba
Module:Scripts/charToScript
Sazgapo viyowoyelo
Module
Kudumbizgana
English
Ŵelengani
Kulemba source
Kuona umo mayambilo
Vilwelo
Vilwelo
move to sidebar
kubisa
Vyakuchita
Ŵelengani
Kulemba source
Kuona umo mayambilo
Vya masiku ghose
Ivo vikwiza pano
Vyaku sintha
Kwezgela chinthu
Va jani lino
Penjani URL yakufupikizgika
Sangululani kodi ya QR
Kaonekelo
move to sidebar
kubisa
Chenjezgo:
Mundanjile mu akaunti yinu. Pala mulembenge chilichose IP adilesi yinu waliyose waionenge. Pala
mwanjila
mu akaunti yinu
panji
mwapanga akaunti
, vyakulemba vinu vyose viŵenge mu zina linu, na uwemi unyake.
Anti-spam check. Do
not
fill this in!
local subexport = {} -- Copied from [[Module:Unicode data]]. local floor = math.floor local function binaryRangeSearch(codepoint, ranges) local low, mid, high low, high = 1, ranges.length or require "Module:table".length(ranges) while low <= high do mid = floor((low + high) / 2) local range = ranges[mid] if codepoint < range[1] then high = mid - 1 elseif codepoint <= range[2] then return range, mid else low = mid + 1 end end return nil, mid end -- Copied from [[Module:Unicode data]]. local function linearRangeSearch(codepoint, ranges) for i, range in ipairs(ranges) do if codepoint < range[1] then break elseif codepoint <= range[2] then return range end end end local function compareRanges(range1, range2) return range1[1] < range2[1] end -- Save previously used codepoint ranges in case another character is in the -- same range. local rangesCache = {} --[=[ Takes a codepoint or a character and finds the script code (if any) that is 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]]. Converts the character to a codepoint. Returns a script code if the codepoint is in the list of individual characters, or if it is in one of the defined ranges in the 4096-character block that it belongs to, else returns "None". ]=] local charToScriptData function subexport.charToScript(char) charToScriptData = charToScriptData or mw.loadData("Module:scripts/recognition data") local t = type(char) local codepoint if t == "string" then local etc codepoint, etc = mw.ustring.codepoint(char, 1, 2) if etc then error("bad argument #1 to 'charToScript' (expected a single character)") end elseif t == "number" then codepoint = char else error(("bad argument #1 to 'charToScript' (expected string or a number, got %s)") :format(t)) end local individualMatch = charToScriptData.individual[codepoint] if individualMatch then return individualMatch else local range if rangesCache[1] then range = linearRangeSearch(codepoint, rangesCache) if range then return range[3] end end local index = floor(codepoint / 0x1000) range = linearRangeSearch(index, charToScriptData.blocks) if not range and charToScriptData[index] then range = binaryRangeSearch(codepoint, charToScriptData[index]) if range then table.insert(rangesCache, range) table.sort(rangesCache, compareRanges) end end return range and range[3] or "None" end end function subexport.findBestScriptWithoutLang(text) text = require("Module:utilities").get_plaintext(text) local scripts = {} for character in text:gmatch("[%z\1-\127\194-\244][\128-\191]*") do local script = subexport.charToScript(character) if script ~= "None" then scripts[script] = (scripts[script] or 0) + 1 end end local bestScript local greatestCount = 0 for script, count in pairs(scripts) do if count > greatestCount then bestScript = script greatestCount = count end end bestScript = bestScript or "None" return require("Module:scripts").getByCode(bestScript) end return subexport
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Kuleka
Wowili wakalembelo
(julani mu windo lanyuwani)
Preview page with this template
Wikidata entities used in this page
Module:Scripts/charToScript
: Sitelink, Description: en
Nkhwaska yagwiliskika apa:
Module:Scripts/charToScript/doc
(
lemba
)
Kufufuza
Kufufuza
Kulemba
Module:Scripts/charToScript
Sazgapo viyowoyelo
Add topic