Haven't posted too recently and I just made this so I figured I'd post it.
Probably some things that could've been done easier but oh wells.
The hexdec will work on its own but the char might not always work.
$char()
//echo -a $char(Rawr &# 124 ; asdf) - returns Rawr | asdf
//echo -a $char(Rawr &# x9F ; asdf) - returns Rawr Ÿ asdf
Note: No spaces between the # and ;
$hexdec()
//echo -a $hexdec(1F) - returns 31
//echo -a $hexdec(1FAE9CB) - returns 33221067
I made this to be used with sockets (used in an $htmlfree or something).
Eh, guess that's it.
alias char {
var %x $regex(char,$1,/&#(x?[a-f\d]*);/gi), %y $1
while (%x) {
var %z $remove($regml(char,%x),x), %z $iif($regex(%z,/[a-f]/i),$hexdec(%z),$regml(char,%x))
var %y $replace(%y,$+(&#,$regml(char,%x),;),$chr(%z))
dec %x
}
return %y
}
alias hexdec {
var %x $len($1)
var %y 1
var %z 0
while (%y <= %x) {
var %b $iif($mid($1,$+(-,%y),1) isin ABCDEF,$gettok(10 11 12 13 14 15,$findtok(A B C D E F,$v1,1,32),32),$v1)
var %a $instok(%a,$calc(%b * (16 ^ %z)),$calc($numtok(%a,43) + 1),43)
inc %y
inc %z
}
return $calc(%a)
}
Base is pretty simple, the mirc help file just makes it seem complicated.
The $base identifier is basically just
$base(number, what base your number is, and what base you want to convert it to, how many digits you want it, and how precise)
10 is the decimal base, 2 is binary, and 16 is hexadecimal. Meaning
$base(45,10,2) would return 101101, $base(45,10,16) returns 2D. You can convert numbers back by simply swapping 10 and 2 or 16. So
$base(101101,2,10) would return 45... etc
The 4th and 5th parameters are option, but zerobase (the 4th parameter) is pretty much what the least number of digits you want your number to be. So 5 with zerobase of 6 would be 000005. Precision is how many digits you want to limit it after the decimal point.