မေႃႇၵျူး:string utilities: လွင်ႈပႅၵ်ႇပိူင်ႈ ၼႂ်းၵႄႈ လွင်ႈၶူၼ်ႉၶႆႈ
Content deleted Content added
Saimawnkham (ဢုပ်ႇဢူဝ်း) ၵေႃႉ ၶိုၼ်ၶိုၼ်း လွင်ႈၶူၼ်ႉၶႆႈ 88282 Tags: Undo Reverted |
mNo edit summary Tags: Manual revert Reverted |
||
ထႅဝ် 102:
-- 4-byte codepoint, F4.
-- Make sure it doesn't decode to over U+10FFFF.
if text:byte(c.byte +
error("String " .. text .. " is not UTF-8.")
end
ထႅဝ် 507:
function export.lcfirst(text)
return uclcfirst(text, true)
end
-- Almost identical to mw.text.nowiki, but with minor changes to be identical to the PHP equivalent: ";" always escapes, and colons in certain protocols only escape after regex \b. Also about 2-3 times as fast.
function export.nowiki(text)
return (text
:gsub("[\"&'<=>%[%]{|};]", {
["\""] = """, ["&"] = "&", ["'"] = "'",
["<"] = "<", ["="] = "=", [">"] = ">",
["["] = "[", ["]"] = "]", ["{"] = "{",
["|"] = "|", ["}"] = "}", [";"] = ";"
})
:gsub("%f[^%z\r\n][#*: \n\r\t]", {
["#"] = "#", ["*"] = "*", [":"] = ":",
[" "] = " ", ["\n"] = " ", ["\r"] = " ",
["\t"] = "	"
})
:gsub("(%f[^%z\r\n])%-(%-%-%-)", "%1-%2")
:gsub("__", "__")
:gsub("://", "://")
:gsub("([IP]?[MRS][BFI][CDN])([\t\n\f\r ])", function(m1, m2)
if m1 == "ISBN" or m1 == "RFC" or m1 == "PMID" then
return m1 .. m2:gsub(".", {
["\t"] = "	", ["\n"] = " ", ["\f"] = "",
["\r"] = " ", [" "] = " "
})
end
end)
:gsub("[%w_]+:", {
["bitcoin:"] = "bitcoin:", ["geo:"] = "geo:", ["magnet:"] = "magnet:",
["mailto:"] = "mailto:", ["matrix:"] = "matrix:", ["news:"] = "news:",
["sip:"] = "sip:", ["sips:"] = "sips:", ["sms:"] = "sms:",
["tel:"] = "tel:", ["urn:"] = "urn:", ["xmpp:"] = "xmpp:"
}))
end
|