php如何将其他编码转utf8
sharpest
阅读:17
2023-03-17 12:59:14
评论:0
php将其他编码转成utf8的方法:1、创建一个PHP示例文件;2、找出字符串本身的编码;3、通过mb_convert_encoding转换为utf-8编码即可。
本文操作环境:Windows7系统,PHP7.4版,Dell G3电脑。
php 怎么将其他编码 转utf8?
php将任意编码的内容转换成utf-8
思路
先找出字符串本身的编码,再转换为utf-8编码。
方法
function str_to_utf8 ($str = '') { $current_encode = mb_detect_encoding($str, array("ASCII","GB2312","GBK",'BIG5','UTF-8')); $encoded_str = mb_convert_encoding($str, 'UTF-8', $current_encode); return $encoded_str; }
本文参考链接:https://www.yisu.com/zixun/621269.html
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。