idHttp 乱码 问题(5分)

  • 主题发起人 主题发起人 linuxping
  • 开始时间 开始时间
L

linuxping

Unregistered / Unconfirmed
GUEST, unregistred user!
代码:
const
Site='http://www.iciba.com/search?s=大';
begin
IdHTTP1.Host:='http://www.iciba.com';
IdHTTP1.HTTPOptions:=IdHTTP1.HTTPOptions+[hoForceEncodeParams];
IdHTTP1.HandleRedirects:=True;
IdHTTP1.Request.AcceptCharSet:='GB18030';
IdHTTP1.Request.AcceptLanguage:='ch';
try
mmo1.Lines.Text:=IdHTTP1.Get(Site);
except
on E:EidException do
ShowMessage(IntToStr(IdHTTP1.Responsecode));
else
ShowMessage('normal error ');
end;

mmo1里出现乱码
 
老兄,详细点好不好?
麻烦您写几行代码出来...
 
乱码片段如下:
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;utf-8&quot;>
<head>
<title>閲戝北璇嶉湼鎼滅储-鍏嶈垂鍦ㄧ嚎璇嶅吀鏌ヨ瘝缈昏瘧__大</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; />
<meta http-equiv=&quot;Content-Language&quot; content=&quot;UTF-8&quot; />
<meta content=&quot;鑻辫?,鐖辫瘝闇?鏌ヨ瘝,缈昏瘧,璇嶉湼璞嗚眴,鑻辫?瀛︿範绀惧尯,鍒掕瘝缈昏瘧&quot; name=&quot;Keywords&quot; />
<meta content=&quot;閲戝北杞?欢鍏?徃璇嶉湼瀹舵棌鎵撻
 
utf8问题
对方网站的编码是utf8,你找个gb2312的就可以
 
能不能对indy做些设置而达到目的~~~~希望大家讨论下indy~~

有几个编码方面的函数
TidURI.ParamsEncode
TIdURI.URLDecode()
TIdURI.URLEncode()
TIdURI.PathEncode()
UTF8Decode
UTF8Encode 用法不太清楚..............

另外
IdHTTP1.Request.Authentication
IdHTTP1.AuthenticationManager 不是差不多的么?
idhttp1.Request.URL,IdHTTP1.Request.Host这个不是已经由idhttp1.host指定了么?
IdHTTP1.Request.AcceptCharSet,IdHTTP1.Request.AcceptLanguage字符集和语言? GB2312当然是中国中文?
IdHTTP1.Request.SetHeaders设置协议头?怎么个用法? 给几个例子..
 
接受答案了.
 
后退
顶部