none
vb6 Winsock发送HTTP数据包,返回数据部分乱码,头大ing.......... RRS feed

  • 问题

  • 本人小鸟,用Winsock发了个HTTP数据包请求网页,然后返回的东西如下:
      HTTP/1.1 200 OK
    Date: Wed, 07 Jul 2010 01:54:19 GMT
    Server: Apache
    Content-Language: zh-CN, cn
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 6044
    Keep-Alive: timeout=25, max=500
    Connection: Keep-Alive
    Content-Type: text/html;charset=GBK

    鹷覸?'玺P5;:擑?被嵫-3衦€戊滈贃c%朵Jr涕摌?灿$膭?i蠖'羪1l{f?谝?軧美冫?蓲_睊曰93祎u秣
    哼隵閪4筷紃w槬r(瑾lVX歧▕f檽儸k狑oR媺怒躐必L曩仆f+y幒RTs愩??:i) 埐7"S淲鄆* 瞺'
    愬?珪?誏愩B^!d?协龂F窩P蟹妢/聈8閏/臣\u袸S^r绀e禟?組?缊+;[=?籆=y耏O`?-U莿P
    槕9O惀?盢谇J^??P瘉Q?眢8?<寚&擉 W??I瞧?忲u峖庉遉K,-?娡l>泘>72;?軫非撚滓[祸x嫖
    置?=絒?護俓+耵Vr鮖蟈錆?,?銙[汩地陉叠?6[?昙決翑D??w8l7~BX襝┴m}-眧 .............
    ..................

    上面是Http Analy监测出来的返回数据

    我程序中是如下处理返回数据的

      Dim gData() As Byte
      ReDim gData(bytesTotal) As Byte
      cSocket.GetData gData, vbString
      For i = 0 To bytesTotal - 1
        AllData = AllData & Chr(gData(i))
      Next
      Text4.Text = Text4.Text & vbCrLf & AllData
    
    显示的结果是:


    HTTP/1.1 200 OK
    Date: Wed, 07 Jul 2010 02:11:25 GMT
    Server: Apache
    Content-Language: zh-CN, cn
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Keep-Alive: timeout=25, max=500
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=GBK

    a
    &
    1785




    _



    各位前辈,受累给检查检查,该怎么做才能把乱码
    的问题解决,最好能具通用性。谢谢啦~~~~~~~
    2010年7月7日 3:27

答案