Copy CodeThe code is as follows:
/********************************************
*
* Function Name: GET_UTF8_TO_GB ($value)
* Function: UTF8 encoded string converted into GB2312 encoding
* Author: Liu Xianzhong
* Date: 2011-11-09
*
********************************************/
function Get_utf8_to_gb ($value) {
$value _1= $value;
$value _2 = @iconv ("Utf-8", "Gb2312//ignore", $value _1),//Use @ To resist the error, if a character in the conversion string does not have a corresponding character in the target character set, then the part after that character is ignored. ; that is, the result string content is incomplete, and you want to use//ignore
$value _3 = @iconv ("gb2312", "Utf-8//ignore", $value _2);
if (strlen ($value _1) = = strlen ($value _3))
{
return $value _2;
}else
{
return $value _1;
}
}
/********************************************
*
* Function Name: Get_gb_to_utf8 ($value)
* Function: GB2312 encoded string converted into UTF8 encoding
* Author: Liu Xianzhong
* Date: 2011-11-09
*
********************************************/
function Get_gb_to_utf8 ($value) {
$value _1= $value;
$value _2 = @iconv ("gb2312", "Utf-8//ignore", $value _1);
$value _3 = @iconv ("Utf-8", "Gb2312//ignore", $value _2);
if (strlen ($value _1) = = strlen ($value _3))
{
return $value _2;
}else
{
return $value _1;
}
}
?>
http://www.bkjia.com/PHPjc/326637.html www.bkjia.com true http://www.bkjia.com/PHPjc/326637.html techarticle Copy the code as follows:? PHP/******************************************** * * Function Name: GET_UTF8_TO_GB ($value) * for Using: UTF8 encoded string converted to GB2312 encoding * Author: ...