asp输出uft-8格式的xml文件

hnyou 2009-12-22 05:02:02
我的代码,不管我怎么弄,,它输出的中文文字都还是乱码。。。弄了1下午没有进展,请高手帮忙。。。多谢。。

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<%

%>
<%
Response.CodePage = 65001
Response.Charset="UTF-8"
Response.ContentType = "text/html"

db="../db/xiao.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
conn.Open connstr


sql="select * from about where lb=1 order by px desc"
set rs=conn.execute(sql)
xmlfile=server.mappath("../about.xml")
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(xmlfile,True)
MyFile.WriteLine("<?xml version=""1.0"" encoding=""utf-8""?>")
MyFile.WriteLine("<caidan>")
do while not rs.eof
lmname=rs("lmname")

aaa="<nei Name=""" & lmname & """ neiURL=""about.asp?id=" & rs("id") & """></nei>"
MyFile.WriteLine(aaa)
rs.movenext
loop
MyFile.WriteLine("</caidan>")
MyFile.Close

%>
<a href="admin.asp">返回</a>
...全文
90 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ender129 2009-12-22
  • 打赏
  • 举报
回复
Response.CodePage = 65001
Response.Charset="UTF-8"
Response.ContentType = "text/html"
这三句话改成下面的三行格式 放在最上面的最上面
试试
<%@ CODEPAGE=65001%>
<%Response.CodePage=65001%>
<%Response.Charset="UTF-8"%>


Anlige 2009-12-22
  • 打赏
  • 举报
回复
用stream输出,不要用fso,stream可以设置文本的编码格式
hookee 2009-12-22
  • 打赏
  • 举报
回复
不需要<meta>, 不能有 <a>这样的html代码
1 文件本身用utf-8编码,(记事本打开,另存为,选编码)
2 <?xml>之前不能输出任何字符,包括空格
3 Response.ContentType = "text/xml"

<%
Response.Charset="UTF-8"
Response.ContentType = "text/xml"
%><?xml version="1.0" encoding="utf-8"?>
<caidan>
<nei/>
</caidan>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧