Home >Backend Development >PHP Tutorial >GB系编码怎么转换utf-8

GB系编码怎么转换utf-8

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 11:35:251263browse

GB系编码如何转换utf-8
我尝试用getid3类库从mp3文件中提取歌曲信息,大多数中文歌曲都正常,但少部分文件有乱码的情况。

// 这是提取出来的字符,及它的base64编码
var_dump($str, base64_encode($str));
// string(16) "???????±"
// string(24) "w5DDhMOLw4bCv8OxwrPCsQ=="

// 检测字符编码,得出的结果是 CP936
mb_detect_encoding($str, 'GBK, gb2312, GB18030, ISO-8859-1, ASCII, UTF-8', true)

// 我尝试转换此比编码,但得出的结果还是不理想
mb_convert_encoding($str, 'UTF-8', 'CP936')
// string(24) "脨脛脣脝驴帽鲁卤"

因为CP936和gbk, gb2312相兼容,所以结果都是一样的。

编码 utf-8
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn