Home > php教程 > php手册 > body text

CP936 converted to UTF-8

WBOY
Release: 2016-10-15 10:31:47
Original
3912 people have browsed it

I recently wrote a crawling script. Most of the content captured is normal, but a small amount of it is garbled

Detect the character encoding and the result is CP936

mb_detect_encoding(<span style="color: #800080;">$str</span>, 'GBK, gb2312, GB18030, ISO-8859-1, ASCII, UTF-8', <span style="color: #0000ff;">true</span>)
Copy after login

Try to convert this encoding, but the result is still garbled

mb_convert_encoding($str, 'UTF-8', 'CP936');
氓聧掳氓潞娄盲赂聙70氓虏聛猫聙聛氓陇麓莽聦楼盲潞碌7氓虏聛氓楼鲁氓颅漏猫聙聦猫垄芦忙聧聲
Copy after login

Finally found out that this can be transcoded

iconv('utf-8', 'latin1', $str);
Copy after login
iconv('utf-8','latin1//IGNORE', $str);
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!