Text conversion

Text conversion

This is just a simple little setup that allows you to do conversions from binary <--> text and hex <--> text.

Postat de Copyright Categorie Review user Vizualizari Data
BLKoldSUN - Math Cod testat 633 2022-11-20 12:37:21

;;This is just a simple little setup that allows you to do conversions from binary <--> text and hex <--> text.

alias bin {
  var %return = $iif($isid, return, echo -ag)
  ;// Binary to Text
  if ($regex($1, /([01]{8})/gSi)) %return $regsubex($1, /(\d{8})/gSi, $chr($base(\t, 2, 10)))
  ;// Text to Binary
  else %return $regsubex($1, /(.)/gSi, $base($asc(\t), 10, 2, 8))
}
alias hex2txt $iif($isid, return, echo -ag) $regsubex($1, /([0-9A-F]{2})/gSi, $chr($base(\t, 16, 10)))
alias txt2hex $iif($isid, return, echo -ag) $regsubex($1, /(.)/gSi, $base($asc(\t), 10, 16, 2))