各位同行:
如何将TCP协议传送过来的二进制编码转换成Ascll编码???
小弟先谢谢了!

解决方案 »

  1.   

    str格式,例:'091234'function HexToChar(Str: string): string;
    var
      i: integer;
      buf1: array[0..100] of byte;
    begin
      for i := 0 to (length(Str) div 2 - 1) do
      begin
        buf1[i] := strtoint('$' + copy(Str, i * 2 + 1, 2));
        Result := Result + char(buf1[i]);
      end;
    end;function CharToHex(Str: string): string;
    var
      i: integer;
      ch: char;
    begin
      for i := 1 to (length(str)) do
      begin
        ch := Str[i];
        Result := Result + inttohex(byte(ch), 2);
      end;
    end;