■■■■■■■■■■■■ AJAX .responseText 中文乱码 的一些问题。 [已经解决] | 悬赏分:0- 问题已经结束 |
问题1:
若文档为非UTF-8编码,如GB2312,用xmlhttp.responseText时,中文显示乱码。
我照网上的方法,在ASP头中设置 response.charset="gb2312",则正常了。
但是 如果是 HTML 等静态文档怎么设置?
(只能用xmlhttp.responseText直接显示中文;若是文件另存为UTF-8或responseBody再编码,就不用回复了)
问题2:
xmlhttp.open("get",url);
当url是 UTF-8的网页,如http://www.google.com
或url是 http://www.qq.com http://www.163.com 就是正常的中文,
但若是 http://www.sina.com.cn http://www.baidu.com 中文就是乱码。
这是什么原因呢?
(我试了他们的HTML文档,也是输出的正常中文,会不会是因为WEB服务器的原因?)
谢谢!
| | 发表者:xia 于 2007-01-09 22:14:31 |
| 最佳答案 |
Function BytesToBstr(body,Cset)
dim objstream
set 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
set objstream = nothing
End Function
查看详细:http://community.csdn.net/Expert/topic/4717/4717502.xml | | 回答者:yuelao 于 2007-01-09 22:14:31 | |
|  |
|