php 检测字符编码mb_detect_encoding()函数
文章提供这款mb_detect_encoding函数是一款可以检测你使用的字符串是什么编码,然后返回字符串编码字符,下面是一个简单应用实例.
function asciitog( $brand ) { $cha =mb_detect_encoding( $brand ); if ( $cha == 'utf-8' ) { $brand2 = iconv( $cha , "gb2312" , $brand ); } $cha2 =mb_detect_encoding( $brand2 ); if ( $cha2 != 'ascii' ){ $brand = $brand2 ; } return $brand ; //开源代码phpfensi测试数据 }mb_detect_encoding
语法:string mb_detect_encoding ( string $str [, mixed $encoding_list = mb_detect_order() [, bool $strict = false ]] )
说明:mb_detect_encoding 用来检测字符串所使用编码,并返回相对应编码字符串.
查看更多关于php 检测字符编码mb_detect_encoding()函数 - php函数的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did30854