您的位置:首页 > 运维架构

indy10 idpop3接收邮件标题乱码

2014-09-16 11:55 561 查看
indy10 idpop3接收邮件标题乱码

修改IdGlobal.pas

function BytesToString(const ***alue: TIdBytes; const AStartIndex: Integer;
  const ALength: Integer = -1; AByteEncoding: TIdTextEncoding = nil
  {$IFDEF STRING_IS_ANSI}; ADestEncoding: TIdTextEncoding = nil{$ENDIF}
  ): string; overload;
var
  LLength: Integer;
  {$IFDEF STRING_IS_ANSI}
  LBytes: TIdBytes;
  {$ENDIF}
begin
  {$IFDEF STRING_IS_ANSI}
  LBytes := nil; // keep the compiler happy
  {$ENDIF}
  LLength := IndyLength(***alue, ALength, AStartIndex);
  if LLength > 0 then begin
    AByteEncoding:=nil;
    TIdTextEncoding.GetBufferEncoding(***alue,AByteEncoding);
    EnsureEncoding(AByteEncoding);
    {$IFDEF STRING_IS_UNICODE}
    Result := AByteEncoding.GetString(***alue, AStartIndex, LLength);
    {$ELSE}
    EnsureEncoding(ADestEncoding);
    LBytes := Copy(***alue, AStartIndex, LLength);
    if AByteEncoding <> ADestEncoding then begin
      LBytes := TIdTextEncoding.Convert(AByteEncoding, ADestEncoding, LBytes);
    end;
    SetString(Result, PAnsiChar(LBytes), Length(LBytes));
    {$ENDIF}
  end else begin
    Result := '';
  end;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: