-
<?php
-
-
-
-
-
-
-
-
-
function get_utf8_to_gb($value){
-
$value_1= $value;
-
$value_2 = @iconv( "utf-8", "gb2312//IGNORE",$value_1);//使用@抵制错误,如果转换字符串中,某一个字符在目标字符集里没有对应字符,那么,这个字符之后的部分就被忽略掉了;即结果字符串内容不完整,此时要使用//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 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;
-
}
-
}
-
?>