您的位置:首页 > 理论基础 > 计算机网络

idhttp控件Post含中文返回值的解析

2017-06-10 21:34 323 查看
使用indy中的idhttp控件在D7和XE平台下,对于接收含中文返回值的解析

网页使用的是UTF8

参考代码来源

http://bbs.csdn.net/topics/391077242

http://www.cnblogs.com/del/archive/2011/12/30/2307965.html

D7下

TJ := TStringList.Create;
TJ.Append(jo.AsString);
FH:=utf8decode(IdHTTP1.Post(Str, TJ));
TJ.Free;


XE下

procedure TForm1.Button1Click(Sender: TObject);
var
T: TStringStream;
ts: TStringList;
SvrUrl, postUrl: string;
begin
SvrUrl := 'http://app.25hours.cc:6077/webservice/25hours.asmx/StruUp';
postUrl := '';
ts := TStringList.Create;
ts.Text := 'data={"ShopID":1,"SyncVer":200}';

T := TStringStream.Create('', tencoding.UTF8);
IdHTTP1.Post(SvrUrl + postUrl, ts, T);
Memo1.Text := T.DataString;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  utf-8 indy idhttp post 中文