欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Flex 读取非UTF-8中文数据乱码问题的解决方案

程序员文章站 2022-03-03 18:40:49
...
(转自ria.args.cn)
//使用URLStream取代URLLoader来读取GB数据
private function loadGBTrans():void{
var request:URLRequest = new URLRequest(gbURL);
var loader:URLStream = new URLStream();
loader.addEventListener(Event.COMPLETE, onloadGBTrans);
loader.load(request);
}



//将读取的内容进行转换后输出,GB的数据被正确显示
private function onloadGBTrans(e:Event):void{
var stream:URLStream = e.currentTarget as URLStream;
var result:String = stream.readMultiByte(stream.bytesAvailable, "gb2312");
ta.text += "\n转换读取GB数据:\n"+result+"\n";
}
相关标签: Flex Java