var str: string;
begin
  str := IntToHex(ord('a'), 2);
end;

解决方案 »

  1.   

    好像不行呀。。
    我试了一下,发现str:=IntToHex(ord('a'),2);后
    str=‘’
    怎么回事??
      

  2.   

    function HexToStr(mHex: string): string;
    var
      I: Integer;
    begin
      Result := '';
      for I := 1 to Length(mHex) div 2 do
        if IsInteger('$' + mHex[I * 2 - 1] + mHex[I * 2]) then
          Result := Result + Chr(StrToInt('$' + mHex[I * 2 - 1] + mHex[I * 2]));
    end; { HexToStr }function StrToHex(mStr: string): string;
    var
      I: Integer;
    begin
      Result := '';
      for I := 1 to Length(mStr) do Result := Result + IntToHex(Ord(mStr[I]), 2);
    end; { StrToHex }
      

  3.   

    function HexToStr(mHex: string): string;
    var
      I: Integer;
    begin
      Result := '';
      for I := 1 to Length(mHex) div 2 do
        if IsInteger('$' + mHex[I * 2 - 1] + mHex[I * 2]) then
          Result := Result + Chr(StrToInt('$' + mHex[I * 2 - 1] + mHex[I * 2]));
    end; { HexToStr }function StrToHex(mStr: string): string;
    var
      I: Integer;
    begin
      Result := '';
      for I := 1 to Length(mStr) do Result := Result + IntToHex(Ord(mStr[I]), 2);
    end; { StrToHex }