Module:Unicode data: Difference between revisions
EnWikiAdmin (talk | contribs) m 1 revision imported |
is_Latin(): when returning false as the first return value, also return character position of first non-Latn character as second return value; for use in {{lang}}, {{langx}}, {{transliteration}} error messaging; |
||
Line 440: | Line 440: | ||
local Latn = false | local Latn = false | ||
local i = 0; -- indexer for use in error messages | |||
for codepoint in mw.ustring.gcodepoint(str) do | for codepoint in mw.ustring.gcodepoint(str) do | ||
i = i + 1; -- bump the indexer | |||
local script = lookup_script(codepoint) | local script = lookup_script(codepoint) | ||
Line 448: | Line 450: | ||
elseif not (script == "Zyyy" or script == "Zinh" | elseif not (script == "Zyyy" or script == "Zinh" | ||
or script == "Zzzz") then | or script == "Zzzz") then | ||
return false | return false, i -- abandon as not Latn; identify the offending character's position | ||
end | end | ||
end | end | ||
return Latn | return Latn, (not Latn and i) or nil -- when <Latn> false, return offending charactor's position as second return value; nil else | ||
end | end | ||