I was asked by a friend if mIRC had both Escape and Unescape aliases similar to the VB/Javascript functions.
Seeing as there is no native aliases to complete the task I decided to just write a couple aliases to do the same thing, with the exception of returning output with %u prefixed four digit (%uxxxx) UTF escape sequences (It does however process UTF (en|de)codes if they are %xx%xx form).
So in this case it's actually more of a mix of the (Un)Escape/(En|De)codeURI functions. Due to this fact, /Escape input can be URL encoded by specifying url as the first parameter. You don't need to specify url to Unescape/decode a URL, only to Escape/encode
tl;dr: Basically an input of $escape(Hello World!) would return "Hello%20World%21".
and an input of $Unescape(Hello%20World%21) would return "Hello World!".
To install, just copy the code into your remotes tab.
To use, type /Escape or /Unescape or use as an identifier.
Examples:
/escape String to be encoded here
$escape(String to be encoded here)
/escape url http://url.to-be-encoded.com/File with spaces or special chars.ext
$escape(url,http://url.to-be-encoded.com/File with spaces or special chars.ext)
---
/unescape String%20to%20be%20decoded%20here
$unescape(String%20to%20be%20decoded%20here)
/unescape http://url.to-be-decoded.com/File%20with%20spaces%20or%20special%20chars.ext $unescape(http://url.to-be-decoded.com/File%20with%20spaces%20or%20special%20chars.ext)
alias escape {
if (!$1) { echo $color(info) * /escape: insufficient parameters | halt }
var %str = $iif($1 = url,$2-,$1-), %noesc = @*-_+./, %urlesc = %noesc $+ ?,:&=$#, %escset = $iif($1 == url,%urlesc,%noesc), %i = 1, %escstr
while (%i <= $len(%str)) {
var %c = $mid(%str,%i,1)
if (%c !isalnum) && (%c !isin %escset) { var %escstr = $+(%escstr,$chr(37),$base($asc(%c),10,16)) }
else { var %escstr = $+(%escstr,%c) }
inc %i
}
$iif($isid,return,echo -a) %escstr
}
alias unescape {
if (!$1) { echo $color(info) * /unescape: insufficient parameters | halt }
var %i = 1, %unescstr
while (%i <= $len($1-)) {
var %c = $mid($1-,%i,1)
if (%c = $chr(37)) { var %c = $remove($mid($1-,%i,3),$chr(37)), %unescstr = $+(%unescstr,$replace($chr($base(%c,16,10)),$chr(32),;spce;)) | inc %i 3 }
else { var %unescstr = $+(%unescstr,$replace(%c,$chr(32),;spce;)) | inc %i }
}
$iif($isid,return,echo -a) $replace(%unescstr,;spce;,$chr(32))
}