鸿 网 互 联 www.68idc.cn

delphi idhttp post 普通提交乱码处理

来源:互联网 作者:佚名 时间:2021-12-14 17:55
var IdHTTP1:TIdHTTP; postStream : TStringStream; Wstr:WideString;res:WideString;beginIdHTTP1 := TidHTTp.create(nil); try Wstr:= 'aaccount=' + aaccount; Wstr:=Wstr+''+'passwd=' +passwd; postStream:=TStringStream.Create(ansitoUTF8(Wstr)); Id
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;  用stringlist POST提交时会乱码,改用该方法后解决。来源:https://blog.csdn.net/weixin_30622181/article/details/95023193
网友评论
<