delphi idhttp post 普通提交乱码处理

var
  IdHTTP1:TIdHTTP;
  postStream : TStringStream;
  Wstr:WideString;

res:WideString; begin IdHTTP1 := TidHTTp.create(nil); try Wstr:= 'aaccount=' + aaccount; Wstr:=Wstr+'&'+'passwd=' +passwd; postStream:=TStringStream.Create(ansitoUTF8(Wstr)); IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded'; try res:=Utf8ToAnsi(IdHTTP1.Post(infoURl,postStream)); except on E:Exception do begin MsgBox('错误信息:' +e.message); end; end; vJson := SO(res); end;

  

用stringlistPOST提交时会乱码,改用该方法后解决。

 

posted @ 2018-05-23 09:19  周黔  阅读(3378)  评论(2编辑  收藏  举报