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 读取image组件转换base64编码

Delphi 关于字符串的一些使用技巧

Delphi删除目录及其子目录

Delphi xe android platform uses-permission[2] androidmanifest.xml 配置

Delphi 比较两个日期是否大于n天

Delphi 以系统权限运行程序的代码

Delphi 拷贝文件夹内所有内容

Delphi 获取本机 hostname ip address

Delphi获取access中的表名代码

Delphi firedac sqlite不能插入"&"符号

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



打赏

取消

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

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

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

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

评论

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