function HexToBin(mHex: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(mHex) do
case mHex[I] of
'0' : Result := Result + '0000';
'1' : Result := Result + '0001';
'2' : Result := Result + '0010';
'3' : Result := Result + '0011';
'4' : Result := Result + '0100';
'5' : Result := Result + '0101';
'6' : Result := Result + '0110';
'7' : Result := Result + '0111';
'8' : Result := Result + '1000';
'9' : Result := Result + '1001';
'a', 'A': Result := Result + '1010';
'b', 'B': Result := Result + '1011';
'c', 'C': Result := Result + '1100';
'd', 'D': Result := Result + '1101';
'e', 'E': Result := Result + '1110';
'f', 'F': Result := Result + '1111';
else Result := Result + ' ';
end;
end; { HexToBin }
看看我的转换,转出来就是不对!
function hextoascii(input:string;var output:string):boolean;
var
i,j:integer;
len:integer;
str:string;
bf:pchar;
aa:string;
begin
result:=false;
getmem(bf,1);
len:=length(input);
output:='';
for i:=1 to len do
begin
str:=input[i];
hextobin(pchar(str),bf,1);
output:=output+strpas(bf);
end;