Sephiroth
http://sephiroth.scifi-action.de/board/

$hex/$unhex
http://sephiroth.scifi-action.de/board/viewtopic.php?f=4&t=36
Seite 1 von 1

Autor:  Sephiroth [ 18. März 2008 00:23 ]
Betreff des Beitrags:  $hex/$unhex

;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,±±)
}

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/