note 84592 modified in function.mb-detect-encoding by danbrown
| From: | danbrown@php.net | Date: | Mon, 21 Jul 2008 16:30:16 +0000 |
| Subject: | note 84592 modified in function.mb-detect-encoding by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142430@lists.php.net to get a copy of this message | ||
<?php
/*
*QQ: 290359552
* conver to Utf8 if $str is not equals to 'UTF-8'
*/
function convToUtf8($str)
{
if( mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK")!="UTF-8" )
{
return iconv("gbk","utf-8",$str);
}
else
{
return $str;
}
}
?>
--was--
/*
*QQ: 290359552
* conver to Utf8 if $str is not equals to 'UTF-8'
*/
function convToUtf8($str)
{
if( mb_detect_encoding($str,"UTF-8, ISO-8859-1, GBK")!="UTF-8" )
{
return iconv("gbk","utf-8",$str);
}
else
{
return $str;
}
}
http://php.net/manual/en/function.mb-detect-encoding.php