PHP判断变量内容是什么编码(gbk?utf-8) mb_detect_encoding
程序员文章站
2022-06-15 11:42:02
...
mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK"); 获取编码类型function convToUtf8($str) { if( mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK")!="UTF-8" ) {//判断是否不是UTF-8编码,如果不是UTF-8编码,则转换为UTF-8编码 return iconv("gbk","utf-8",$str); } else { return $str; } }复制代码 |
下一篇: 能把汉字转化为拼音的一个函数