我们来利用一个vb函数对中文字符的转换,即可使乱码的中文恢复正常。。。
| 以下是代码片段: <script language="vbscript"> Function bytes2BSTR(vIn) Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode strReturn = "" For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode < &H80 Then strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End If Next bytes2BSTR = strReturn End Function </script> |
调用时这样写即可。。。
| 以下是调用片段: var response = bytes2BSTR(xmlHttp.responsebody); test1.innerHTML = response; |
注意:一定要引用responsebody,不用能responseText;
原载: No.1网络工作室 http://www.noonenet.cn/