PHP检测当前字符串编码并转码UTF-8

180it 2020-11-17 AM 912℃ 0条

1、获取当前字符串编码

$encode = mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK"));

2、将字符串编码转为UTF-8

$str = mb_convert_encoding($str, 'UTF-8', $encode);
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

PHP检测当前字符串编码并转码UTF-8