Code Utf-8
I try to use the Getid3 class Library from the MP3 file to extract the song information, most Chinese songs are normal, but a small number of files have garbled situation.
This is the extracted character, and it's Base64 encoded
Var_dump ($str, Base64_encode ($STR));
String (16) "Ðäëæ¿ñ³±"
String ("w5ddhmolw4bcv8oxwrpcsq==")
Detect character encoding, the result is CP936
Mb_detect_encoding ($str, ' GBK, gb2312, GB18030, Iso-8859-1, ASCII, UTF-8 ', true)
I try to convert this than coding, but the results are still not ideal
Mb_convert_encoding ($str, ' UTF-8 ', ' CP936 ')
String ("????") Donkey Hat lu Halogen "
Because CP936 and GBK are compatible with gb2312, the results are the same.
Reply to discussion (solution)
$s = "w5ddhmolw4bcv8oxwrpcsq==";
$s = base64_decode ($s);//ðäëæ¿ñ³± (this is UTF-8 encoded)
echo Utf8_decode ($s);//Heart like frenzy (note that this is GBK encoded)
Since your system does not recognize the GBK encoding, each extended ASCII character that makes up the GBK string is iso-8859-1 to utf-8 encoding conversion
You can write, too.
echo iconv (' GBK ', ' Utf-8 ', iconv (' Utf-8 ', ' latin1 ', $s));
It is also easy to determine if the Utf-8 encoding is 2 bytes
Echo (Ord ($s {0}) & 0xf0) = = 0xc0? ' Yes ': ' No ';
I try to use the Getid3 class Library from the MP3 file to extract the song information, most Chinese songs are normal, but a small number of files have garbled situation.
This is the extracted character, and it's Base64 encoded
Var_dump ($str, Base64_encode ($STR));
String (16) "Ðäëæ¿ñ³±"
String ("w5ddhmolw4bcv8oxwrpcsq==")
Detect character encoding, the result is CP936
Mb_detect_encoding ($str, ' GBK, gb2312, GB18030, Iso-8859-1, ASCII, UTF-8 ', true)
I try to convert this than coding, but the results are still not ideal
Mb_convert_encoding ($str, ' UTF-8 ', ' CP936 ')
String ("????") Donkey Hat lu Halogen "
Because CP936 and GBK are compatible with gb2312, the results are the same.
This should still have to be your server support some kind of code, you can do the conversion, if not supported, you cannot use the program to convert the