I think all understand :)
Example, type: //echo $url_encode(тест)
in mIRC >= v7.0
Returns: %D1%82 %D0%B5 %D1%81 %D1%82 (without spaces, of course)
(two bytes for one unicode russian symbol)
alias url_encode {
var %i = 1, %len = $len($1), %str
while (%i <= %len) {
var %char = $asc($mid($1,%i,1)), %i = %i + 1
if (%char isnum 33-47) || (%char isnum 48-57) || (%char isnum 58-64) || (%char isnum 65-90) || (%char isnum 97-122) var %str = $+(%str,$chr(%char))
elseif (%char < 128) var %str = $+(%str,%,$base(%char,10,16,2))
elseif (%char < 2048) var %str = $+(%str,%,$base($calc(192 + $int($calc(%char / 64))),10,16,2),%,$base($calc(128 + (%char % 64)),10,16,2))
elseif (%char < 65536) var %str = $+(%str,%,$base($calc(224 + $int($calc(%char / 4096))),10,16,2),%,$base($calc(128 + ($int($calc(%char / 64)) % 64)),10,16,2),%,$base($calc(128 + (%char % 64)),10,16,2))
elseif (%char < 2097152) var %str = $+(%str,%,$base($calc(240 + $int($calc(%char / 262144))),10,16,2),%,$base($calc(128 + ($int($calc(%char / 4096)) % 64)),10,16,2),%,$base($calc(128 + ($int($calc(%char / 64)) % 64)),10,16,2),%,$base($calc(128 + (%char % 64)),10,16,2))
}
return %str
}
@Spoofing How did you figure out the math for this?
It's the same as my old one here -->> http://www.hawkee.com/snippet/6515/
I only did it like that because I was having trouble figuring out how to use bit shifting in mSL. I finally sorted it out with bit shifting here -->> http://www.mircscripts.org/showdoc.php?type=code&id=4403