这是html的encoding。你去查html4的标准,里面有的。

解决方案 »

  1.   

    function TFM_SMTP.EncodeBase64(Source:string):string;
    var
      Times, LenSrc, i: Integer;
      x1, x2, x3, x4: Char;
      xt: Byte;
    begin
      Result := '';
      LenSrc := Length(Source);
      if LenSrc mod 3 = 0 then
        Times := LenSrc div 3
      else
        Times := LenSrc div 3 + 1;
      for i := 0 to Times - 1 do
      begin
        if LenSrc >= (3 + i * 3) then
        begin
          x1 := BaseTable[(ord(Source[1 + i * 3]) shr 2)+1];
          xt := (ord(Source[1 + i * 3]) shl 4) and 48;
          xt := xt or (ord(Source[2 + i * 3]) shr 4);
          x2 := BaseTable[xt + 1];
          xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
          xt := xt or (Ord(Source[3 + i * 3]) shr 6);
          x3 := BaseTable[xt + 1];
          xt := (ord(Source[3 + i * 3]) and 63);
          x4 := BaseTable[xt + 1];
        end
        else if LenSrc >= (2 + i * 3) then
        begin
          x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2) + 1];
          xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
          xt := xt or (Ord(Source[2 + i * 3]) shr 4);
          x2 := BaseTable[xt + 1];
          xt := (Ord(Source[2 + i * 3]) shl 2) and 60;
          x3 := BaseTable[xt + 1];
          x4 := '=';
        end else
        begin
          x1 := BaseTable[(Ord(Source[1 + i * 3]) shr 2)+1];
          xt := (Ord(Source[1 + i * 3]) shl 4) and 48;
          x2 := BaseTable[xt + 1];
          x3 := '=';
          x4 := '=';
        end;
        Result := Result + x1 + x2 + x3 + x4;
      end;
    end;
    这是个字符串转换为ANSI
      

  2.   

    const
      BaseTable = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
      

  3.   

    http://search.csdn.net/Expert/topic/768/768064.xml?temp=.1791803
      

  4.   

    function AnsiToUnicode(Ansi: string):string;var  s:string;  i:integer;  j,k:string[2];  a:array [1..1000] of char;begin  s:='';  StringToWideChar(Ansi,@(a[1]),500);  i:=1;  while ((a[i]<>#0) or (a[i+1]<>#0)) do begin    j:=IntToHex(Integer(a[i]),2);    k:=IntToHex(Integer(a[i+1]),2);    s:=s+k+j;    i:=i+2;  end;    Result:=s;end;
    反编码的函数 
    function ReadHex(AString:string):integer;begin  Result:=StrToInt('$'+AString)end;
    function UnicodeToAnsi(Unicode: string):string;var  s:string;  i:integer;  j,k:string[2];begin  i:=1;  s:='';  while i<Length(Unicode)+1 do begin    j:=Copy(Unicode,i+2,2);    k:=Copy(Unicode,i,2);    i:=i+4;    s:=s+Char(ReadHex(j))+Char(ReadHex(k));  end;  if s<>'' then    s:=WideCharToString(PWideChar(s+#0#0#0#0))  else    s:='';  Result:=s;end;