PHP decryption Unicode and escape encrypted strings, unicodeescape_php tutorial

Source: Internet
Author: User
Tags 0xc0 utf 8

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 ('/\/ ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.