indy10 idpop3接收邮件标题乱码
修改IdGlobal.pas
function BytesToString(const AValue: 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(AValue, ALength, AStartIndex);
if LLength > 0 then begin
AByteEncoding:=nil;
TIdTextEncoding.GetBufferEncoding(AValue,AByteEncoding);
EnsureEncoding(AByteEncoding);
{$IFDEF STRING_IS_UNICODE}
Result := AByteEncoding.GetString(AValue, AStartIndex, LLength);
{$ELSE}
EnsureEncoding(ADestEncoding);
LBytes := Copy(AValue, 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;