日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

delphi函数,识别字符集编码

發(fā)布時(shí)間:2025/3/15 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 delphi函数,识别字符集编码 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

紀(jì)念不用 Delphi 開發(fā)7周年

?函數(shù),獲取web page文本,識(shí)別字符集編碼;

?1?function?CreateHttpRequest(proxyServer:?string?=?'';?proxyPort:?integer?=?0):
?2???TIdHTTP;
?3?function?DecodeHttpRequestText(InString:?string):?string;
?4?implementation
?5?
?6?{$R?*.dfm}
?7?
?8?function?DecodeHttpRequestText(InString:?string):?string;
?9?begin
10???Result?:=?UpperCase(InString);
11?? //google,baidu,cnblogs,localhost等測(cè)試ok...
12???if?(Pos('CHARSET=',?Result)?=?0)?or?(pos('=UTF-',?Result)?<>?0)?then
13?????InString?:=?Utf8Decode(InString);
14???Result?:=?InString;
15?end;
16?
17?function?CreateHttpRequest(proxyServer:?string?=?'';?proxyPort:?integer?=?0):
18???TIdHTTP;
19?begin
20???Result?:=?TIdHTTP.Create(nil);
21???with?Result?do
22???begin
23?????HandleRedirects?:=?true;
24?????HTTPOptions?:=?[hoForceEncodeParams];
25?????ReadTimeout?:=?30000;
26?????Request.Accept?:=
27???????'image/gif,?image/x-xbitmap,?image/jpeg,?image/pjpeg,?application/x-shockwave-flash,?*/*';
28?????Request.AcceptLanguage?:=?'zh-cn';
29?????Request.ContentType?:=?'application/x-www-form-urlencoded';
30?????Request.UserAgent?:=
31???????'Mozilla/4.0?(compatible;?MSIE?6.0;?Windows?NT?5.1;?SV1;?.NET?CLR?4.0)';
32?????if?(proxyServer?<>?'')?then
33???????proxyParams.ProxyServer?:=?proxyServer;?//'代理服務(wù)器地址';
34?????if?proxyPort?<>?0?then
35???????proxyParams.ProxyPort?:=?proxyPort;?//'代理服務(wù)器端口';
36???end;
37?end;
38?
39?procedure?TForm1.btn1Click(Sender:?TObject);
40?var
41???getstr:?string;
42?begin
43???mmo1.Lines.Clear;
44???getstr?:=DecodeHttpRequestText(?CreateHttpRequest().Get(edt1.Text));
45???mmo1.Lines.Add(getstr);
46?
47?end;

?

轉(zhuǎn)載于:https://www.cnblogs.com/Chinasf/archive/2012/01/11/2319811.html

總結(jié)

以上是生活随笔為你收集整理的delphi函数,识别字符集编码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。