How to load MP3 ID3 garbled characters in as3

Source: Internet
Author: User
Tags id3

As3 loading MP3 ID3 garbled solution most MP3 ID3 uses GBK/gb2312 character encoding. In As2, usedcodepage can be used to solve the problem, but in as3, even if usedcodepage is used, sound still uses utf8 encoding to read ID3 information when loading MP3 files, this makes the ID3 read by a large number of MP3 players garbled and cannot be displayed normally. This is a very unpleasant thing. The following code can be used to convert the ID3 information that is incorrectly encoded by UTF-8 from garbled code to readable code.

/*
* ID3 Information encoding and conversion
*/
Private function encodeutf8 (STR: string): String {
VaR oribytearr: bytearray = new bytearray ();
Oribytearr. writeutfbytes (STR );
VaR tempbytearr: bytearray = new bytearray ();
// Trace (STR );
For (VAR I = 0; I <oribytearr. length; I ++ ){
If (oribytearr [I] = 194 ){
Tempbytearr. writebyte (oribytearr [I + 1]);
I ++;
} Else if (oribytearr [I] = 195 ){
Tempbytearr. writebyte (oribytearr [I + 1] + 64 );
I ++;
} Else {
Tempbytearr. writebyte (oribytearr [I]);
}
}
Tempbytearr. Position = 0;
Return tempbytearr. readmultibyte (tempbytearr. bytesavailable, "Chinese ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.