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提交时会乱码,改用该方法后解决。

猜你喜欢

转载自www.cnblogs.com/zhqian/p/9075252.html