asp后台修改xml后,xml显示中文正常,但在flash读取xml,flash中显示中文乱码,请高手指点~~~
本地IIS测试,通过asp后台修改xml后,xml文件内是正常的中文显示,但在flash中显示乱码,然后打开xml文件点击保存,flash中却又正常显示中文。asp、xm...
本地IIS测试,通过asp后台修改xml后,xml文件内是正常的中文显示,但在flash中显示乱码,然后打开xml文件点击保存,flash中却又正常显示中文。asp、xml都是utf-8,感觉是asp写入xml时有问题,小弟不太懂asp语言,请高手指点,万分感激!!!
展开
4个回答
展开全部
如果你的ASP后台是用FSO来读取XML文件的,那么就有出现问题的可能;因为采用FSO来修改文件,保存后的文件格式是ansi。
下面是我自己做过的一个FSO代码,
同样的,生产的文件内编码也是ansi。
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.OpenTextFile(Server.MapPath(filepath),2,True)
TextStr="<?xml version='1.0' encoding='UTF-8' ?>"
TextStr=TextStr&"<items>"
TextStr=TextStr&"</items>"
fout.Write TextStr
fout.close
只要有<?xml version='1.0' encoding='UTF-8' ?>而且必须为第一行!!!
而FLASH中也设置好System.useCodepage = true;
一般是不会出现乱码的。
我做了很多站都是通过这样方式来修改的。
下面是我自己做过的一个FSO代码,
同样的,生产的文件内编码也是ansi。
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.OpenTextFile(Server.MapPath(filepath),2,True)
TextStr="<?xml version='1.0' encoding='UTF-8' ?>"
TextStr=TextStr&"<items>"
TextStr=TextStr&"</items>"
fout.Write TextStr
fout.close
只要有<?xml version='1.0' encoding='UTF-8' ?>而且必须为第一行!!!
而FLASH中也设置好System.useCodepage = true;
一般是不会出现乱码的。
我做了很多站都是通过这样方式来修改的。
展开全部
flash第一针加上他
System.useCodepage = true
System.useCodepage = true
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<script language="javascript">
<!--
if (window == top)top.location.href = "Default.asp";
// -->
</script>
<%
wl_sss=request("classid")
sub wlxmlsub2(xxxxx)
set wlxml = server.CreateObject("ADODB.RecordSet")
sql="select * from [webshow] where classid="&xxxxx&" and isgood order by orderby asc,id desc"
set wlxml = conn.Execute (Sql)
if wlxml.bof and wlxml.eof then
foolcat = foolcat + vbcrlf
else
imgA=""
imgB=""
do while not wlxml.eof
imgA=wlxml("img")
imgB=wlxml("img2")
bg_color_c=wlxml("bg_color")
if imgA<>"" then imgA=replace(wlxml("img"),"/UploadFiles/","")
if imgB<>"" then imgB=replace(wlxml("img2"),"/UploadFiles/","")
if bg_color_c<>"" then bg_color_c=replace(wlxml("bg_color"),"#","")
foolcat = foolcat + " <image Thumb="""&imgA&""" Large="""&imgB&""" Caption="""&wlxml("Title")&""" Colour="""&bg_color_c&""">" + vbcrlf
foolcat = foolcat + " <copy><![CDATA[<p>"&wlxml("content")&"</p>]]></copy>" + vbcrlf
foolcat = foolcat + " </image>"
wlxml.movenext
foolcat = foolcat + vbcrlf
loop
end if
wlxml.close
set wlxml = nothing
end sub
sub wlxmlsub1()
set wlxml = server.CreateObject("ADODB.RecordSet")
sql="select DISTINCT classid from [webshow]"
set wlxml = conn.Execute (Sql)
if wlxml.bof and wlxml.eof then
foolcat = foolcat + "" + vbcrlf
else
do while not wlxml.eof
foolcat = foolcat + " <gallery Name="""&wlxml("classid")&""" Folder=""../UploadFiles/"">" + vbcrlf
call wlxmlsub2(wlxml("classid"))
wlxml.movenext
if not wlxml.eof then
foolcat = foolcat + " </gallery>" + vbcrlf
else
foolcat = foolcat + vbcrlf
end if
loop
end if
wlxml.close
set wlxml = nothing
end sub
foolcat = "<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>"+vbcrlf
foolcat = foolcat + "<content>"+vbcrlf
call wlxmlsub1()
foolcat = foolcat + "</content>" + vbcrlf
%>
<%
'------------------------------------------------------
'读取文件 ReadTxtFile(FileName)
'------------------------------------------------------
Function ReadTxtFile(FileName)
Dim fso,f1,ts,FilePath
FilePath=server.mappath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(FilePath,1,1)
ReadTxtFile = ts.ReadAll
set ts=nothing
set fso=nothing
End Function
'------------------------------------------------------------
'生成JS\ASP\HTML等文件用这个。
'------------------------------------------------------------
Function WriteTxtFile(Text,FileName)
path=Server.MapPath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(path,true)
f1.Write (Text)
f1.Close
End Function
'------------------------------------------------------------
'生成XML文件用这个。
'------------------------------------------------------------
Function WriteTxtFilexml(XMLStr,FileName)
set oStream = server.CreateObject("ADODB"&"."&"Stream")
oStream.Type=2
oStream.Mode=3
oStream.Open()
oStream.Charset = "utf-8"
oStream.WriteText XMLStr
oStream.Position= 0
oStream.SaveToFile server.MapPath(FileName),2
oStream.Close()
set oStream = nothing
End Function
if wl_sss="0" then
call WriteTxtFilexml(foolcat,"..\content.xml")
end if
response.write "<script language=javascript>alert('恭喜您,最新网上展厅列表成功生成调用文件!');history.back(-1);</script>"
response.End()
%>
分享我的生成XML文件功能给你。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<script language="javascript">
<!--
if (window == top)top.location.href = "Default.asp";
// -->
</script>
<%
wl_sss=request("classid")
sub wlxmlsub2(xxxxx)
set wlxml = server.CreateObject("ADODB.RecordSet")
sql="select * from [webshow] where classid="&xxxxx&" and isgood order by orderby asc,id desc"
set wlxml = conn.Execute (Sql)
if wlxml.bof and wlxml.eof then
foolcat = foolcat + vbcrlf
else
imgA=""
imgB=""
do while not wlxml.eof
imgA=wlxml("img")
imgB=wlxml("img2")
bg_color_c=wlxml("bg_color")
if imgA<>"" then imgA=replace(wlxml("img"),"/UploadFiles/","")
if imgB<>"" then imgB=replace(wlxml("img2"),"/UploadFiles/","")
if bg_color_c<>"" then bg_color_c=replace(wlxml("bg_color"),"#","")
foolcat = foolcat + " <image Thumb="""&imgA&""" Large="""&imgB&""" Caption="""&wlxml("Title")&""" Colour="""&bg_color_c&""">" + vbcrlf
foolcat = foolcat + " <copy><![CDATA[<p>"&wlxml("content")&"</p>]]></copy>" + vbcrlf
foolcat = foolcat + " </image>"
wlxml.movenext
foolcat = foolcat + vbcrlf
loop
end if
wlxml.close
set wlxml = nothing
end sub
sub wlxmlsub1()
set wlxml = server.CreateObject("ADODB.RecordSet")
sql="select DISTINCT classid from [webshow]"
set wlxml = conn.Execute (Sql)
if wlxml.bof and wlxml.eof then
foolcat = foolcat + "" + vbcrlf
else
do while not wlxml.eof
foolcat = foolcat + " <gallery Name="""&wlxml("classid")&""" Folder=""../UploadFiles/"">" + vbcrlf
call wlxmlsub2(wlxml("classid"))
wlxml.movenext
if not wlxml.eof then
foolcat = foolcat + " </gallery>" + vbcrlf
else
foolcat = foolcat + vbcrlf
end if
loop
end if
wlxml.close
set wlxml = nothing
end sub
foolcat = "<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes""?>"+vbcrlf
foolcat = foolcat + "<content>"+vbcrlf
call wlxmlsub1()
foolcat = foolcat + "</content>" + vbcrlf
%>
<%
'------------------------------------------------------
'读取文件 ReadTxtFile(FileName)
'------------------------------------------------------
Function ReadTxtFile(FileName)
Dim fso,f1,ts,FilePath
FilePath=server.mappath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(FilePath,1,1)
ReadTxtFile = ts.ReadAll
set ts=nothing
set fso=nothing
End Function
'------------------------------------------------------------
'生成JS\ASP\HTML等文件用这个。
'------------------------------------------------------------
Function WriteTxtFile(Text,FileName)
path=Server.MapPath(FileName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile(path,true)
f1.Write (Text)
f1.Close
End Function
'------------------------------------------------------------
'生成XML文件用这个。
'------------------------------------------------------------
Function WriteTxtFilexml(XMLStr,FileName)
set oStream = server.CreateObject("ADODB"&"."&"Stream")
oStream.Type=2
oStream.Mode=3
oStream.Open()
oStream.Charset = "utf-8"
oStream.WriteText XMLStr
oStream.Position= 0
oStream.SaveToFile server.MapPath(FileName),2
oStream.Close()
set oStream = nothing
End Function
if wl_sss="0" then
call WriteTxtFilexml(foolcat,"..\content.xml")
end if
response.write "<script language=javascript>alert('恭喜您,最新网上展厅列表成功生成调用文件!');history.back(-1);</script>"
response.End()
%>
分享我的生成XML文件功能给你。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
如果你的ASP后台是用FSO来读取XML文件的,那么就有出现问题的可能;因为采用FSO来修改文件,保存后的文件格式是ansi。
下面是我自己做过的一个FSO代码,
同样的,生产的文件内编码也是ansi。
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.OpenTextFile(Server.MapPath(filepath),2,True)
TextStr="<?xml version='1.0' encoding='UTF-8' ?>"
TextStr=TextStr&"<items>"
TextStr=TextStr&"</items>"
fout.Write TextStr
fout.close
在xml文件首行写上<?xml version='1.0' encoding='gb2312' ?>如发现有数字65001,则将其改为:936。
在FLASH帧中写上System.useCodepage = true;
应该不会出现乱码的。
下面是我自己做过的一个FSO代码,
同样的,生产的文件内编码也是ansi。
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.OpenTextFile(Server.MapPath(filepath),2,True)
TextStr="<?xml version='1.0' encoding='UTF-8' ?>"
TextStr=TextStr&"<items>"
TextStr=TextStr&"</items>"
fout.Write TextStr
fout.close
在xml文件首行写上<?xml version='1.0' encoding='gb2312' ?>如发现有数字65001,则将其改为:936。
在FLASH帧中写上System.useCodepage = true;
应该不会出现乱码的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询