;usage $hex(<text>)
;usage $unhex(hexcode)
alias hex {
var %z = 0,%y = $len($1),%x
while (%z < %y) {
inc %z
%x = %x $base($asc($mid($1,%z,1)),10,16,2)
}
return %x
}
alias unhex {
var %z = 1,%1 = $remove($1,$chr(32)),%y = $len(%1),%x
while (%z < %y) {
var %a = ±± $+ $chr($base($mid(%1,%z,2),16,10,3)) $+ ±±
%x = %x $+ %a
inc %z 2
}
%x = %x $+ $chr($base($mid(%1,%z,2),16,10,3))
var %y = 32
while (%y) {
var %tok = $gettok(NUL¢Start of Header¢Start of Text¢End of Text¢End of Transmission¢Enquiry¢Acknowledge¢Bell¢Backspace¢Horizontal Tab¢Line Feed¢Vertical Tab¢Form Feed¢Carriage Return¢Shift Out¢Shift In¢Delete¢-free-¢-free-¢-free-¢-free-¢Negative Acknowledge¢Sychronous Idle¢End of Transmission¢Cancel¢End of Medium¢Substidude¢Escape¢File Seperator¢Group Seperator¢Record Seperator¢Unit Seperator¢Space,$calc(%y +1),162)
%x = $replace(%x,$chr(%y),$+($chr(123),$lower(%tok),$chr(125)))
dec %y
}
return $remove(%x,±±)
}