困了一周了,用尽了网上可以搜到的办法,通通都试过了,原来在D7上用的,一切正常,到了XE8上死活不行,返回的中文都是“??????????????????0????????1?????2????”这样的,谁可以帮帮我!!

解决方案 »

  1.   

    用UT8Decode解码试试呢?
      

  2.   

    用过UTF8Decode,UTF8ToAnsi,还有
      

  3.   

        t:=TStringStream.Create('',tencoding.UTF8);
        idhttp1.Post(SvrUrl+postUrl,ts,t);
        Result:=Utf8ToAnsi(t.DataString);或Result:=Utf8Decode(t.DataString);
    或者
        t:=TStringStream.Create('',tencoding.ANSI);
        idhttp1.Post(SvrUrl+postUrl,ts,t);
        Result:=t.DataString;
    都不行,
    确定网站返回的是UTF8的,在Delphi7下也是用IDHttp返回是正常的
      

  4.   

    url能否发上来
      

  5.   

    http://app.25hours.cc:6077/webservice/25hours.asmx/StruUp
    Post:data={"ShopID":1,"SyncVer":200}
    我自己的服务器
      

  6.   

    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;经过测试,没有乱码
    {"error":0,"msg":"表结构升级获取成功!","Count":247,"Stru":[{"ID":201,"SqlStr":"CASE"},{"ID":202,".......
      

  7.   

    引用:
    IdURI;使用:
    TidURI.URLDecode(MyHttp.Get(TIdURI.URLEncode(uploadstr)));
      

  8.   

    找到解决方法了,使用tstringstream作为返回类型,部分代码参考:
    responsejson: tstringstream; 
    responsejson := tstringstream.Create('', 65001); 
    http.post(URL ,StringList , responsejson);    
    Memo1.Lines.Add(responsejson.DataString);  
    responsejson.DataString里面的中文不是乱码了!
    解决方法参考自http://blog.sina.com.cn/s/blog_549f50ec01019cgc.html。
      

  9.   

    之前也找了很多方法,中文用AnsiString,WideString转都不行。
    后来测试:
    delphi7 中中文用 UTF8Encode(inValue);
    java中用URLDecoder.decode(inValue, "utf-8");
    可以