Copy Code code as follows:
<?php
function Unicode_encode ($name)
{
$name = Iconv (' UTF-8 ', ' UCS-2 ', $name);
$len = strlen ($name);
$str = ';
for ($i = 0; $i < $len-1; $i = $i + 2)
{
$c = $name [$i];
$c 2 = $name [$i + 1];
if (ord ($c) > 0)
{///two bytes of text
$str. = ' \u '. Base_convert (Ord ($c), a). Str_pad (Base_convert (Ord ($c 2), 2, 0, str_pad_left);
}
Else
{
$str. = $c 2;
}
}
return $str;
}
Decode Unicode-encoded content
function Unicode_decode ($name)
{
Conversion encoding to convert Unicode encoding into a utf-8 encoding that can be browsed
$pattern = '/([\w]+) | (\\\u ([\w]{4}))/I ';
Preg_match_all ($pattern, $name, $matches);
if (!empty ($matches))
{
$name = ';
for ($j = 0; $j < count ($matches [0]); $j + +)
{
$str = $matches [0][$j];
if (Strpos ($str, ' \\u ') = = 0)
{
$code = Base_convert (substr ($STR, 2, 2), 16, 10);
$code 2 = Base_convert (substr ($STR, 4), 16, 10);
$c = Chr ($code). Chr ($code 2);
$c = Iconv (' UCS-2 ', ' UTF-8 ', $c);
$name. = $c;
}
Else
{
$name. = $str;
}
}
}
return $name;
}