Fischer asked this 7 years ago

Pascal script to convert Hex to ASCII and reverse

how can i convert a hexadecimal string to it equialent ascii in Pascal Script.

For example

Hex => 48656c6c6f20576f726c64

ASCII of the above hex is => HelloWorld

I also need to do the reverse conversion.


Best Answer by pseudoFish 7 years ago

The below Pascal Script will convert a hex string to its equivalent ASCII

 

var instr:string = 'Hello World';
    outstr:string = '';
    i:integer;
    hx:string='';

begin

i := 1;

while i <= length(instr) - 1 DO

    Begin

         hx := instr[i] + instr[i+1];

         outstr := outstr + StrToHex(hx);

          i := i + 2;

    end;

ShowMessage(outstr);