No - the Lua libraries are somewhat sparse for various reasons, while Javascripts are somewhat large for various other reasons.
With the usefulness that is the added utils functions in MUSHClient, though, you can throw together something like this fairly easily:
-- Modes: 1 - escape, 2 - encodeURI, 3 - encodeURIComponent
function escapeURIs(sIn, mode)
find=string.find -- Shortcut to avoid repeat lookups
sOut=""
-- Characters to omit for escape, encodeURI
-- and encodeURIcomponent respectively
searchStrings={[[@*/+]], [[~!@#$&*()=:/,;?+']], [[~!*()']]}
search = searchStrings[mode]
-- Iterate over each character in the string
for char in string.gmatch(sIn, ".") do
-- Check character against omissions and convert
if find(search, char, 1, true) == nil then
sOut=sOut..'%'..utils.tohex(char)
else
sOut=sOut..char
end
end
return sOut
end
This should serve your needs, but be aware it's not comprehensively tested. (I checked it against a few strings in each mode, but that's it.) |