你用TMemoryStream试试,或许是应为2010的string是unicode编码,d6还是ansi的

解决方案 »

  1.   

    你怎么就断定是代码转换的问题呢? 在GET前面加下面一行试试看。IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
      

  2.   

    不是这些问题,是因为返回的内容压缩了,返回实际内容如下:
    /**********************************************
    HTTP/1.1 200 OK
    Date: Thu, 06 Sep 2012 11:27:19 GMT
    Content-Type: text/html;charset=UTF-8
    Transfer-Encoding: chunked
    Connection: keep-alive
    Vary: Accept-Encoding
    Set-Cookie: JSESSIONID=03CDFB6D0A3F939F665E8C1CAA999103; Path=/
    Server: N.WEBPROXY-1.20
    Expires: Thu, 06 Sep 2012 11:27:19 GMT
    Cache-Control: max-age=0
    Content-Encoding: gzip15
    ?***************************/
    要自己用gzip解压缩
      

  3.   

    procedure DecompressGZip(AInStream, AOutStream: TStream);procedure TDemoForm.DecompressGZip(AInStream, AOutStream: TStream);
    var
      pb1, pb2: Byte;
    begin
      AInStream.Seek(1, 0);
      AInStream.Read(pb1, 1);
      AInStream.Seek(2, 0);
      AInStream.Read(pb2, 1);
      AInStream.Position := 0;
      AOutStream.Position := 0;
      if (pb1 = $8B) and (pb2 = $8) then //gzip
        ZDecompressStream2(AInStream, AOutStream, 47)
      else
        AOutStream.CopyFrom(AInStream, AInStream.Size);
    end;自己去下个ZLibEx单元,里边有ZDecompressStream2函数
      

  4.   

    用不着这么费劲吧。
    你不是用 Indy 的 Http 吗
    在 Indy Misc 里有个 TIdCompressorZLib
    在IdHttp 里,指定属性 Compressor = 这个 TIdCompressorZLib
    全自动解码,嘿
      

  5.   

    http://my.csdn.net/my/code/detail/18338
      

  6.   

    另外:
    rocedure TForm2.Button1Click(Sender: TObject);
    var
      ResponseStream: TStringStream;
      i: integer;
      URL: string;
    begin
      ResponseStream := TStringstream.Create('', 936);
      IdHTTP1.Request.AcceptEncoding := 'identity';
      URL := 'http://www.118100.cn/action/secweborder/isCTMobile.do?mobile=' + edit1.Text;
      IdHTTP1.Get(URL, ResponseStream);
      Memo1.Lines.Add('-------------------------');
      Memo1.Lines.Add(URL);
      // 这里不再需要对UTF8解码,因为它本来就不是UTF8
      Memo1.Lines.Add(ResponseStream.DataString); 
      Freeandnil(ResponseStream);
    end;
      

  7.   

    谢谢大家了,从delphi改成PHP了
      

  8.   

    楼上的真搞笑~!--- 跟人签名 ----------------
    高价收药、收药、北京收药:
    http://www.woshouyao.com/index.php