Home > php教程 > PHP源码 > PHP 自动检测编码转换

PHP 自动检测编码转换

PHP中文网
Release: 2016-06-01 14:32:43
Original
1232 people have browsed it

跳至

//自动检测内容是编码进行转换 get_encoding($data,"GB2312");
function get_encoding($data,$to)
{
$encode_arr = array('UTF-8','ASCII','GBK','GB2312','BIG5','JIS','eucjp-win','sjis-win','EUC-JP');
$encoded = mb_detect_encoding($data, $encode_arr);
$data = mb_convert_encoding($data,$to,$encoded);
return $data;
}
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