有关 TEncoding

有关 TEncoding 求助
这段代码是用在Delphi 2009以上的:

function TMainForm.ToHexString(s: string; encode: TEncoding): string;
var TmpStr: string;
  ByteAy: Tbytes;
  tmpByte: Byte;
begin
  ByteAy := encode.GetBytes(s);
  TmpStr := '';
  for tmpByte in ByteAy do
  TmpStr := Format('%s%.2x', [tmpstr, tmpbyte]);
  Result := TmpStr;
end;

如何修改使之可以用在delphi7中?或者要用到什么三方控件?高分求助!

------解决方案--------------------
试一试:
http://www.2ccc.com/article.asp?articleid=5090
------解决方案--------------------
看代码是把string转成16进制的文本,可以使用BinToHex函数,代码是:
Delphi(Pascal) code

  Len := Length(s);
  SetLength(Result, Len shl 1);
  BinToHex(s, PChar(Result), Len);

------解决方案--------------------
Delphi(Pascal) code
function StringToHex(S: String): String;
var I: Integer;
begin
  Result:= '';
  for I := 1 to length (S) do
    Result:= Result+IntToHex(ord(S[i]),2);
end;


function HexToString(H: String): String;
var I: Integer;
begin
  Result:= '';
  for I := 1 to length (H) div 2 do
    Result:= Result+Char(StrToInt('$'+Copy(H,(I-1)*2+1,2)));
end;