Flash读取XML文件出现的中文乱码问题
原因:中文乱码,不用说都是编码惹的祸。Flash是使用UTF-8编码的。而一般我们保存文本文件时(也就是XML文件),用的编码是GB2321、ANSI或者Unicode。
有2种办法可以解决:
1、XML文件用的编码,就是这一句“<?xml version="1.0" encoding="UTF-8"?>”注意后面的是“encoding="UTF-8"”。特别注意保存文件时,文件编码选择使用"UTF-8",,这样解析时就不会有乱码问题了。使用"Unicode"编码也可以,但这样文件量会相对比较大。
2、在Flash脚本代码前面加上 System.useCodepage = true; 语句,但据说这是下下策的做法,不建议采用。
flash读取外部中文时显示乱码的问题 - [flashy]
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://avant-/logs/27551062.html
1 比较老的解决方案:
加一句:System.useCodepage = true;
此法已经不推荐使用, 这是让flash player使用操作系统的编码。如果系统本身就不支持外部文本的编码格式,则可能仍然是乱码。以下节选自《flash cs3 help 》:“Only use this process when you are loading non-Unicode encoded text from an external location and when this text is encoded with the same code page as the user’s computer.”
2 将外部文本用unicode进行编码:
这种做法应该更通用 。同样摘自《flash cs3 help》:“ To ensure that users on all platforms can view external text files used in your Flash applications, encode all external text files as Unicode and leave thesystem.useCodepageproperty set tofalseby default.”