indy10 idpop3接收邮件标题乱码

indy10  idpop3接收邮件标题乱码

修改IdGlobal.pas


[delphi]  view plain  copy
  1. function BytesToString(const AValue: TIdBytes; const AStartIndex: Integer;  
  2.   const ALength: Integer = -1; AByteEncoding: TIdTextEncoding = nil  
  3.   {$IFDEF STRING_IS_ANSI}; ADestEncoding: TIdTextEncoding = nil{$ENDIF}  
  4.   ): string; overload;  
  5. var  
  6.   LLength: Integer;  
  7.   {$IFDEF STRING_IS_ANSI}  
  8.   LBytes: TIdBytes;  
  9.   {$ENDIF}  
  10. begin  
  11.   {$IFDEF STRING_IS_ANSI}  
  12.   LBytes := nil// keep the compiler happy  
  13.   {$ENDIF}  
  14.   LLength := IndyLength(AValue, ALength, AStartIndex);  
  15.   if LLength > 0 then begin  
  16.     AByteEncoding:=nil;  
  17.     TIdTextEncoding.GetBufferEncoding(AValue,AByteEncoding);  
  18.     EnsureEncoding(AByteEncoding);  
  19.     {$IFDEF STRING_IS_UNICODE}  
  20.     Result := AByteEncoding.GetString(AValue, AStartIndex, LLength);  
  21.     {$ELSE}  
  22.     EnsureEncoding(ADestEncoding);  
  23.     LBytes := Copy(AValue, AStartIndex, LLength);  
  24.     if AByteEncoding <> ADestEncoding then begin  
  25.       LBytes := TIdTextEncoding.Convert(AByteEncoding, ADestEncoding, LBytes);  
  26.     end;  
  27.     SetString(Result, PAnsiChar(LBytes), Length(LBytes));  
  28.     {$ENDIF}  
  29.   end else begin  
  30.     Result := '';  
  31.   end;  
  32. end;  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值