Modulo:IsLatin
Aspetto
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:IsLatin/man (modifica · cronologia)
Sandbox: Modulo:IsLatin/sandbox (modifica · cronologia) · Test: Modulo:IsLatin/test (modifica · cronologia · Esegui)
Esempi di utilizzo
| Testo | Codice | Risultato |
|---|---|---|
| Sport | {{#invoke:IsLatin|IsLatin|Sport}} | 1 |
| Ştefăneşti | {{#invoke:IsLatin|IsLatin|Ştefăneşti}} | 1 |
| 大谷川ユースホステル | {{#invoke:IsLatin|IsLatin|大谷川ユースホステル}} | -1 |
| 55 EUR | {{#invoke:IsLatin|IsLatin|55 EUR}} | 1 |
| £55 | {{#invoke:IsLatin|IsLatin|£55}} | 1 |
| 55$ | {{#invoke:IsLatin|IsLatin|55$}} | 1 |
| 55€ | {{#invoke:IsLatin|IsLatin|55€}} | 1 |
| stringa vuota | {{#invoke:IsLatin|IsLatin|}} | 0 |
| nessun valore | {{#invoke:IsLatin|IsLatin}} | 0 |
--[[
Source script: https://it.wikivoyage.org/wiki/Modulo:IsLatin
Maintainer: Andyrom75
]]
local function _isDefined(s)
return s ~= '' and s
end
local p = {}
function p.IsLatin(frame)
return frame.args and p.IsLatinValue(frame.args[1]) or ''
end
function p.IsLatinValue(txt)
if _isDefined(txt) then
local len = mw.ustring.len(txt)
local pos = 1
while ( pos <= len ) do
local charval = mw.ustring.codepoint(mw.ustring.sub(txt, pos))
-- note 8364 is the € symbol
if charval>687 and charval~=8364 then
return -1
end
pos = pos + 1
end
return 1
else
return 0
end
end
return p