方法一:
<?php
function unicode_encode($name)
{
$name = iconv(
$len = strlen($name);
$str =
for ($i =
{
$c = $name[$i];
$c
if (ord($c) >
{ //兩個字節的文字
$str
}
else
{
$str
}
}
return $str;
}
//將UNICODE編碼後的內容進行解碼
function unicode_decode($name)
{
//轉換編碼
$pattern =
preg_match_all($pattern
if (!empty($matches))
{
$name =
for ($j =
{
$str = $matches[
if (strpos($str
{
$code = base_convert(substr($str
$code
$c = chr($code)
$c = iconv(
$name
}
else
{
$name
}
}
}
return $name;
}
方法二:
function unicode
if(!$str) return $str;
$decode = json_decode($str);
if($decode) return $decode;
$str =
$decode = json_decode($str);
if(count($decode) ==
return $decode[
}
return $str;
}
From:http://tw.wingwit.com/Article/program/PHP/201311/21149.html