Indy10下的TIdhttp控件获取源码乱码的解决方法


本文整理自网络,侵删。

 

 Indy10下使用TIDHTTP出现乱码的原因是因为编码问题,可以使用如下方法来解决!



procedure TWeatherThread.GetWeather;
var
AURL: string;
ANetData: TStringStream;
begin
try
AURL := 'http://www.4936.cn';
ANetData := TStringStream.Create('', TEncoding.GetEncoding(936));
try
ANetData := FIDHttp.Get(AURL);
// ANetData.DataString 就是获取到的源码
finally
ANetData.Free;
end;
except
on E: Exception do
begin
OutputDebugString(PChar('[TWeatherThread.GetWeather]:' + E.Message));
end;
end;
end;

相关阅读 >>

Delphi 将string 转为 array of ansichar

Delphi trim 删除字符串左右两边的空格

Delphi 得到文件创建时间,修改时间,访问时间

Delphi回调函数高级应用

Delphi的listview自动排序

Delphi 获取文件crc和md5

Delphi closehandle的解释

Delphi getrandompassword 生成随机密码

8086 汇编指令手册查询

Delphi tdirectory.tfilterpredicate

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...