加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex中字符编码识别

发布时间:2020-12-15 01:02:06 所属栏目:百科 来源:网络整理
导读:关键:读取开头2个字节,utf-8前3个字节是ef bb bf ,unicode前2个字节是fffe或者feff,ansi则没有这些标志! 搞了一天,终于可以识别各种格式的LRC歌词了。放出部分代码 ??? var strCode:int= this.stream.readByte(); ??????????????? ??? ??? var str:Str
关键:读取开头2个字节,utf-8前3个字节是ef bb bf ,unicode前2个字节是fffe或者feff,ansi则没有这些标志!
搞了一天,终于可以识别各种格式的LRC歌词了。放出部分代码

??? var strCode:int= this.stream.readByte();
??????????????? ??? ??? var str:String = new String();
??????????????????????? trace(strCode);
??????? ??? ??? ??? ??? switch(strCode)
??????? ??? ??? ??? ??? {
??? ??????? ??? ??? ??? ??? case -1:
??? ??? ??????? ??? ??? ??? ??? //第一个字符为-1则是unicode
??? ??? ??????? ??? ??? ??? ??? this.charset="unicode";
??? ??? ??????? ??? ??? ??? ??? this.stream.readByte();
??? ??? ??????? ??? ??? ??? ??? str = this.stream.readMultiByte(this.stream.bytesAvailable,this.charset);
??? ??? ??????? ??? ??? ??? ??? break;
??? ??? ??????? ??? ??? ??? case -17:
??? ??? ??? ??????? ??? ??? ??? //第一个字符为-17则是utf-8
??? ??? ??? ??????? ??? ??? ??? this.charset="utf-8";
??? ??? ??? ??????? ??? ??? ??? this.stream.readByte();
??? ??? ??? ??????? ??? ??? ????
??? ??? ??? ??????? ??? ??? ??? str = this.stream.readMultiByte(this.stream.bytesAvailable,51); font-family:Arial; font-size:14px; line-height:26px; text-align:left">??? ??? ??? ??????? ??? ??? ??? break;
??? ??? ??? ??????? ??? ??? default:
??? ??? ??? ??????? ??? ??? ??? this.charset="ansi";
??? ??? ??? ??????? ??? ??? ??? str = String.fromCharCode(strCode);
??? ??? ??? ??????? ??? ??? ??? str? += this.stream.readMultiByte(this.stream.bytesAvailable,51); font-family:Arial; font-size:14px; line-height:26px; text-align:left">??????? ??? ??? ??? ??? }
??????? ??? ??? ??? ??? trace(str);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读