<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> <script language="javascript"> var xmlhttp=new ActiveXObject("Msxml2.xmlhttp") xmlhttp.open("GET","http://www.sina.com.cn/",false) xmlhttp.send() alert(bytes2BSTR(xmlhttp.ResponseBody)) </script>你也可以保存成本地文件
<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> <script language="javascript"> var xmlhttp=new ActiveXObject("Msxml2.xmlhttp") xmlhttp.open("GET","http://www.sina.com.cn/",false) xmlhttp.send() alert(bytes2BSTR(xmlhttp.ResponseBody)) </script>你也可以保存成本地文件
以前的代码中有这么一句 var len=xmlhttp.responseText.length if(len>20000&&!confirm(len+",是否继续?"))return; body=bytes2BSTR(xmlhttp.responseBody);就可以看出bytes2BSTR的效率问题
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>
<script language="javascript">
var xmlhttp=new ActiveXObject("Msxml2.xmlhttp")
xmlhttp.open("GET","http://www.sina.com.cn/",false)
xmlhttp.send()
alert(bytes2BSTR(xmlhttp.ResponseBody))
</script>你也可以保存成本地文件
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>
<script language="javascript">
var xmlhttp=new ActiveXObject("Msxml2.xmlhttp")
xmlhttp.open("GET","http://www.sina.com.cn/",false)
xmlhttp.send()
alert(bytes2BSTR(xmlhttp.ResponseBody))
</script>你也可以保存成本地文件
如果不是本地访问网络,用#dafault#download最好
1,网速慢,请求时
2,执行效率的解码函数你可以用C#写,简单而且很快。using System.IO;
using System.Net;
using System.Text;private void button1_Click(object sender, System.EventArgs e)
{
byte[] buf = new byte[38192];
WebRequest request = WebRequest.Create(textBox1.Text);
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
int count = resStream.Read(buf, 0, buf.Length);
textBox2.Text = Encoding.Default.GetString(buf, 0, count);
resStream.Close();
}
1,网速慢,请求时
2,执行效率的解码函数你可以用C#写,简单而且很快。using System.IO;
using System.Net;
using System.Text;private void button1_Click(object sender, System.EventArgs e)
{
byte[] buf = new byte[38192];
WebRequest request = WebRequest.Create(textBox1.Text);
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
int count = resStream.Read(buf, 0, buf.Length);
textBox2.Text = Encoding.Default.GetString(buf, 0, count);
resStream.Close();
}
if(len>20000&&!confirm(len+",是否继续?"))return;
body=bytes2BSTR(xmlhttp.responseBody);就可以看出bytes2BSTR的效率问题