PHP decrypts Unicode and escape encrypted strings, Unicodeescape
This article is to share a PHP decrypted Unicode and escape encrypted string function
<?php function Uni_decode ($s) {preg_match_all ('/\&\# ([0-9]{2,5}) \;/', $s, $html _uni); Preg_match_all ('/[\\\%]u ([0-9a-f]{4})/ie ', $s, $js _uni); $source = Array_merge ($html _uni[0], $js _uni[0]); $js = Array (); for ($i =0; $i
>6); $str. =CHR (0x80 | $c & 0x3f); } else if ($c < 0x10000) {$str. =CHR (0xe0 | $c >>12); $str. =CHR (0x80 | $c >>6 & 0x3f); $str. =CHR (0x80 | $c & 0x3f); } else if ($c < 0x200000) {$str. =CHR (0xf0 | $c >>18); $str. =CHR (0x80 | $c >>12 & 0x3f); $str. =CHR (0x80 | $c >>6 & 0x3f); $str. =CHR (0x80 | $c & 0x3f); } return $STR;
} $str = '%u5927%u5bb6%u597d%uff0c I am a ghost!
\u8fd9\u662f\u6d4b\u8bd5\u6587\u672c\uff01 '; echo Uni_decode ($STR); Hello everyone, I am the soul of ghosts!
This is the test text!
Search on the Internet, a lot of PHP implementation of the escape function, similar
function Phpescape ($str) { Preg_match_all ("/[\x80-\xff].| [\x01-\x7f]+/], $STR, $newstr); $ar = $newstr [0]; foreach ($ar as $k = + $v) { if (ord ($ar [$k]) >=127) { $tmpString =bin2hex (iconv ("GBK", "ucs-2", $v)); if (!eregi ("WIN", Php_os)) { $tmpString = substr ($tmpString, 2,2). substr ($tmpString, 0,2); } $reString. = "%u". $tmpString; } else { $reString. = Rawurlencode ($v); } }
The above mentioned is the whole content of this article, I hope you can like.
http://www.bkjia.com/PHPjc/1000260.html www.bkjia.com true http://www.bkjia.com/PHPjc/1000260.html techarticle PHP decryption Unicode and Escape encrypted string, unicodeescape this article to share a PHP decryption Unicode and Escape cryptographic string function PHP functions Uni_decode ($s) {preg_ Match_all ('/\/ ...