if (function_exists('mb_detect_encoding') && function_exists('mb_convert_encoding')) {
// mb_detect_encoding isn't very reliable, to say the least
// detection should still work with a sufficient sample
// of ascii characters
$encoding = mb_detect_encoding($sample);
// mb_detect_encoding() will return FALSE if detection fails
// don't attempt conversion if that's the case
if ($encoding != 'ASCII' && $encoding != 'UTF-8'
&& $encoding !== false
) {
// verify the encoding exists in mb_list_encodings
if (in_array($encoding, mb_list_encodings())) {
$sample = mb_convert_encoding($sample, 'UTF-8', $encoding);
}
}
}
其它编码的字符转utf8编码
最新推荐文章于 2022-11-09 11:23:23 发布