首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

Ajax代理程序自动判断字符编码

整理日期:2007年12月28日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-12/1198843912.html
 //自动判断编码开始
 var charresult = http_request.ResponseText.match(/CharSet=(\S+)\">/i);
 if (charresult != null){
 var Cset = charresult[1];
 }else{Cset = "gb2312"}//对获取不到的网站采用gb2312编码,可自行更改

//自动判断编码结束
 codedtext = bytesToBSTR(http_request.Responsebody,Cset);
 }else{
 codedtext = "Erro";
 }
 return(codedtext);
}

function bytesToBSTR(body,Cset){
var objstream;
objstream = Server.CreateObject("Adodb.Stream");
objstream.Type = 1;
objstream.Mode = 3;
objstream.Open();
objstream.Write(body);
objstream.Position = 0;
objstream.Type = 2;
objstream.Charset = Cset;
bytesToBSTR = objstream.Readtext;
objstream.Close;
return(bytesToBSTR);
}

%>
<body>
<% Response.Write(send_request("http://www.etoow.com")) %>
</body>
</html>
Tags:
Ajax代理程序自动判断字符编码
'http://www.etoow.com/html/2007-12/1198843912.html
1
 
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved