This is a long time ago collected one, do not know who wrote, but after testing no problem ~
JavaScript code
Copy CodeThe code is as follows:
function Phpunescape ($ESCSTR)
{
Preg_match_all ("/%u[0-9a-za-z]{4}|%.{ 2}| [0-9a-za-z.+-_]+/], $ESCSTR, $matches);
$ar = & $matches [0];
$c = "";
foreach ($ar as $val)
{
if (substr ($val, 0, 1)! = "%")
{
$c. = $val;
} elseif (Substr ($val, 1, 1)! = "U")
{
$x = Hexdec (substr ($val, 1, 2));
$c. = Chr ($x);
}
Else
{
$val = Intval (substr ($val, 2), 16);
if ($val < 0x7F)//0000-007f
{
$c. = Chr ($val);
} elseif ($val < 0x800)//0080-0800
{
$c. = Chr (0xC0 | ($val/64));
$c. = Chr (0x80 | ($val% 64));
}
else//0800-FFFF
{
$c. = Chr (0xE0 | (($val/64)/64));
$c. = Chr (0x80 | (($val/64)% 64));
$c. = Chr (0x80 | ($val% 64));
}
}
}
return $c;
}
After escape code:
Copy CodeThe code is as follows:
%u6d4b%u8bd5www.jb51.net%22%22%27%27%3c%3e%26%26
After decoding:
Copy CodeThe code is as follows:
Test Www.jb51.net "" <>&&
http://www.bkjia.com/PHPjc/321170.html www.bkjia.com true http://www.bkjia.com/PHPjc/321170.html techarticle This is a long time ago collected one, do not know who wrote, but after testing no problem ~ JavaScript code Copy Code code is as follows: function Phpunescape ($escstr) {preg_match_all ("/%u[...