flash调用外部数据乱码解决全方案

Posted on May 23, 2005 by Fdream

昨天做了一个IP地址查询器,在计算中心测试时还是正常的(那里用的是windows 2000),回来再看的时候发现怎么弄都不正常了,以前读取asp的时候也没碰到过这种问题,今天总算解决了!
现在把解决乱码的方法总结一下:

1、载入外部的.txt文件和.xml文件
这种情况下一般只需在fla文件的第一帧加上这么一句就没问题了:
System.useCodepage=true;
请务必注意大小写!
还一种方法就是直接把要载入的文件另存为utf-8,因为Unicode是flash直接支持的!

2、从asp文件读取数据

(1)在fla文件的第一帧放这一句:
System.useCodepage=true;
一般也能解决问题,但很多时候仍然会出现乱码!

(2)这时候可以这样:
fla第一帧仍然有这么一句:
System.useCodepage=true;
但是在asp文件的开头加这么一句:
<%Response.Charset="UTF-8"%>

(3)还一种解决方法是:
fla第一帧仍然有这么一句:
System.useCodepage=true;
但是在asp输出的时候采用这样的语句:
Response.Write “fname=”&Server.URLEncode(rs(“username”))
即使用 Server.URLEncode方法!

(4)如果很不幸的以上三种方法都不管用,现在只剩最后一招了:
把fla中第一帧的下面这一句不要了!
System.useCodepage=true;
在asp文件的开头加上这么两句:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.Charset="UTF-8"%>

如果还不行的话大家就看着办吧,偶只知道这么多了,欢迎大家补充和指出错误!

分享 |
Categories:
Flash/AS
Tags:
, ,
Comments:
Leave a comment
Views:
12,010 Views

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>