Heim >php教程 >php手册 >php函数mb_detect_encoding自动识别编码并自动转换成utf8的方法

php函数mb_detect_encoding自动识别编码并自动转换成utf8的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:11:011228Durchsuche

php中有一个自动识别编码的函数mb_detect_encoding(),下面的代码是探测文章编码并自动转换成utf8的方法 //自动识别编码并自动转换成utf8 /* 爱推吧 http://ituibar.com */ function characet($data){ if(!empty($data)){ $fileType=mb_detect_encoding($date

php中有一个自动识别编码的函数mb_detect_encoding(),下面的代码是探测文章编码并自动转换成utf8的方法

//自动识别编码并自动转换成utf8
 /*
 爱推吧 http://ituibar.com
 */
 function characet($data){
 if(!empty($data)){
 $fileType=mb_detect_encoding($date,array('utf-8','GBK','LATIN1','BIG5'));
 if($fileType !='utf-8'){
 $data=mb_convert_encoding($data, 'utf-8',$fileType) ;
 }
 }
 return $date;
 }
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn