xe2 idhttp post乱码的问题
以前用d7、indy9写的程序:用两个函数实现客户端读取服务器端的asp程序生成的xml,一直没什么问题,现在用xe2,用了utf8toansi,utf8decode都会出现乱码,用浏览器却可以正常显示,不知道怎么解决了
function GetdataAsp(AspName:string; StrSql:String):WideString;begin try ConnectUrl := 'Http://'+ConnectIni+AspName; ReSult := postXml(StrSql,ConnectUrl); except on Ex:exception do begin ShowMessage(Ex.Message); assignfile(ErrorF,ExtractFilePath(Application.exename)+'ErrorMessage.txt'); Append(ErrorF); try writeln(ErrorF,DateTimeToStr(now)+' | '+Ex.Message); finally closefile(ErrorF); end; end; end;end;function postXml(const xmlstr, url: WideString): WideString;var idHttp:TIdHTTP; sends:tstrings; IdEncoderMIME1:TIdEncoderMIME; vStream: TMemoryStream;begin result:=''; try idHttp:= TIdHTTP.Create(nil); idHttp.Request.ContentType := 'application/x-www-form-urlencoded'; idhttp.Request.AcceptCharSet := 'UTF-8'; idhttp.Request.AcceptEncoding := 'UTF-8'; idhttp.Request.AcceptLanguage := 'UTF-8'; sends:=tstringlist.Create; sends.Add('strSQL='+(xmlstr)); result:=idhttp.Post(url,sends); except on Ex:exception do begin assignfile(ErrorF,ExtractFilePath(Application.exename)+'ErrorMessage.txt'); Append(ErrorF); try writeln(ErrorF,DateTimeToStr(now)+' | '+Ex.Message); finally closefile(ErrorF); end; end; end; idHttp.Free; sends.Free;