PHPʵÏÖÈ«½Ç×Ö·ûתΪ°ë½Ç·½·¨»ã×Ü

5年以前  |  阅读数:377 次  |  编程语言:PHP 

×i¼oµ¥µÄ½¨


    <?php  
    $str = "£°£±£²£³£Á£Â£Ã£Ä£Æ£×£Ó£Ü£¢£¬£®£¿£¼£¾£u£ý£Û£Ý£ª£¦£Þ£¥£££À£¡¡«£¨£(C)£«£­£u£º£»";  
    echo "$str";  
    echo "<br />";  
    $str = preg_replace('/\xa3([\xa1-\xfe])/e', 'chr(ord(\1)-0x80)', $str);  
    echo $str;

ÕaÊÇÍøÉÏ¿´À´µÄ´uÂe£¬ËuÓеÄÖÐÎıeµaµÄµÚ¶þ¸o×Ö½Ú¼oÈ¥0X80£¨¼´128£(C)ËuµÃµÄÊý×Ö¾ÍÊÇ°e½ÇËuµÃµÄÊý×ÖÁË¡£¶ø/eģʽ±i´iµÄÊÇ£ºÈç¹uÉe¶¨ÁË´ËÐÞÕýu£¬preg_replace() ÔÚÌae»»×Öu´®ÖжÔÄaeÏoÒýÓÃ×÷Õý³£µÄÌae»»£¬½«Æa×÷Ϊ PHP ´uÂeÇoÖµ£¬²¢ÓÃÆa½a¹uÀ´Ìae»»ËuËÑË÷µÄ×Ö*u´®¡£

ÔÚÇUTF-8ģʽÏÂÕa¸oº¯ÊýÊÇ¿ÉÐеÄ,µ«ÊÇUTF-8Ï Õa¸o½*¨¾ÍËƺoÎÞЧ,

½¨¶þ£º


    $queue = Array('£°' => '0', '£±' => '1', '£²' => '2', '£³' => '3', '£´' => '4', '£µ' => '5', '£¶' => '6', '£*' => '7', '£¸' => '8', '£¹' => '9', 
    '£Á' => 'A', '£Â' => 'B', '£Ã' => 'C', '£Ä' => 'D', '£Å' => 'E', '£Æ' => 'F', '£Ç' => 'G', '£È' => 'H', '£É' => 'I', '£Ê' => 'J', 
    '£Ë' => 'K', '£Ì' => 'L', '£Í' => 'M', '£Î' => 'N', '£Ï' => 'O', '£Ð' => 'P', '£Ñ' => 'Q', '£Ò' => 'R', '£Ó' => 'S', '£Ô' => 'T', 
    '£Õ' => 'U', '£Ö' => 'V', '£×' => 'W', '£Ø' => 'X', '£Ù' => 'Y', '£Ú' => 'Z', '£a' => 'a', '£a' => 'b', '£a' => 'c', '£a' => 'd', 
    '£a' => 'e', '£ae' => 'f', '£ç' => 'g', '£e' => 'h', '£e' => 'i', '£e' => 'j', '£e' => 'k', '£i' => 'l', '£i' => 'm', '£i' => 'n', 
    '£i' => 'o', '£ð' => 'p', '£ñ' => 'q', '£o' => 'r', '£o' => 's', '£o' => 't', '£o' => 'u', '£o' => 'v', '£÷' => 'w', '£ø' => 'x', 
    '£u' => 'y', '£u' => 'z');
    echo preg_replace_callback("/([\xEF][\xBC][\x90-\x99]|[\xEF][\xBD][\x81-\x9A\xA1-\xBA])/", 'next_fchar', '£°');
    function next_fchar($matches){
     global $queue;
     return $queue[$matches[1]];
    }

½¨Èý£º


    /**
    * ×Ö*u´®°e½ÇºÍÈ«½Ç¼aÏa»¥×ª»»
    * @param string $str ´ýת»»µÄ×Ö*u´®
    * @param int  $type TODBC:ת»»Îª°e½Ç£»TOSBC£¬×ª»»ÎªÈ«½Ç
    * @return string *µ»Øת»»ºoµÄ×Ö*u´®
    */
    function convertStrType($str, $type) {

        $dbc = array( 
          '£°' , '£±' , '£²' , '£³' , '£´' , 
          '£µ' , '£¶' , '£*' , '£¸' , '£¹' , 
          '£Á' , '£Â' , '£Ã' , '£Ä' , '£Å' , 
          '£Æ' , '£Ç' , '£È' , '£É' , '£Ê' , 
          '£Ë' , '£Ì' , '£Í' , '£Î' , '£Ï' , 
          '£Ð' , '£Ñ' , '£Ò' , '£Ó' , '£Ô' , 
          '£Õ' , '£Ö' , '£×' , '£Ø' , '£Ù' , 
          '£Ú' , '£a' , '£a' , '£a' , '£a' , 
          '£a' , '£ae' , '£ç' , '£e' , '£e' , 
          '£e' , '£e' , '£i' , '£i' , '£i' , 
          '£i' , '£ð' , '£ñ' , '£o' , '£o' , 
          '£o' , '£o' , '£o' , '£÷' , '£ø' , 
          '£u' , '£u' , '£­' , '¡¡' , '£º' ,
          '£®' , '£¬' , '£¯' , '£¥' , '££' ,
          '£¡' , '£À' , '£¦' , '£¨' , '£(C)' ,
          '£¼' , '£¾' , '£¢' , '£§' , '£¿' ,
          '£Û' , '£Ý' , '£u' , '£ý' , '£Ü' ,
          '£u' , '£«' , '£½' , '£ß' , '£Þ' ,
          '£¤' , '£þ' , '£a'

    );

        $sbc = array( //°e½Ç
          '0', '1', '2', '3', '4', 
          '5', '6', '7', '8', '9', 
          'A', 'B', 'C', 'D', 'E', 
          'F', 'G', 'H', 'I', 'J', 
          'K', 'L', 'M', 'N', 'O', 
          'P', 'Q', 'R', 'S', 'T', 
          'U', 'V', 'W', 'X', 'Y', 
          'Z', 'a', 'b', 'c', 'd', 
          'e', 'f', 'g', 'h', 'i', 
          'j', 'k', 'l', 'm', 'n', 
          'o', 'p', 'q', 'r', 's', 
          't', 'u', 'v', 'w', 'x', 
          'y', 'z', '-', ' ', ':',
          '.', ',', '/', '%', ' #',
          '!', '@', '&', '(', ')',
          '<', '>', '"', '\'','?',
          '[', ']', '{', '}', '\\',
          '|', '+', '=', '_', '^',
          '£¤','~', '`'

    );
    if($type == 'TODBC'){
    return str_replace( $sbc, $dbc, $str ); //°e½Çµ½È«½Ç
    }elseif($type == 'TOSBC'){
    return str_replace( $dbc, $sbc, $str ); //È«½Çµ½°e½Ç
    }else{
    return $str;
    }
    }

½¨ËÄ£º


    /**
    * ½«Ò»¸o×Ö´®Öк¬ÓÐÈ«½ÇµÄÊý×Ö×Ö*u¡¢×Öĸ¡¢¿Õ¸ñ»o'%+-()'×Ö*uת»»ÎªÏaÓ¦°e½Ç×Ö*u
    *
    * @access public
    * @param string $str ´ýת»»×Ö´®
    *
    * @return string $str ´¦Àiºo×Ö´®
    */
    function make_semiangle($str)
    {
    $arr = array('£°' => '0', '£±' => '1', '£²' => '2', '£³' => '3', '£´' => '4',
    '£µ' => '5', '£¶' => '6', '£*' => '7', '£¸' => '8', '£¹' => '9',
    '£Á' => 'A', '£Â' => 'B', '£Ã' => 'C', '£Ä' => 'D', '£Å' => 'E',
    '£Æ' => 'F', '£Ç' => 'G', '£È' => 'H', '£É' => 'I', '£Ê' => 'J',
    '£Ë' => 'K', '£Ì' => 'L', '£Í' => 'M', '£Î' => 'N', '£Ï' => 'O',
    '£Ð' => 'P', '£Ñ' => 'Q', '£Ò' => 'R', '£Ó' => 'S', '£Ô' => 'T',
    '£Õ' => 'U', '£Ö' => 'V', '£×' => 'W', '£Ø' => 'X', '£Ù' => 'Y',
    '£Ú' => 'Z', '£a' => 'a', '£a' => 'b', '£a' => 'c', '£a' => 'd',
    '£a' => 'e', '£ae' => 'f', '£ç' => 'g', '£e' => 'h', '£e' => 'i',
    '£e' => 'j', '£e' => 'k', '£i' => 'l', '£i' => 'm', '£i' => 'n',
    '£i' => 'o', '£ð' => 'p', '£ñ' => 'q', '£o' => 'r', '£o' => 's',
    '£o' => 't', '£o' => 'u', '£o' => 'v', '£÷' => 'w', '£ø' => 'x',
    '£u' => 'y', '£u' => 'z',
    '£¨' => '(', '£(C)' => ')', '¡²' => '[', '¡³' => ']', '¡¾' => '[',
    '¡¿' => ']', '¡¼' => '[', '¡½' => ']', '¡°' => '[', '¡±' => ']',
    '¡®' => '[', ''' => ']', '£u' => '{', '£ý' => '}', '¡¶' => '<',
    '¡*' => '>',
    '£¥' => '%', '£«' => '+', '¡ª' => '-', '£­' => '-', '¡«' => '-',
    '£º' => ':', '¡£' => '.', '¡¢' => ',', '£¬' => '.', '¡¢' => '.',
    '£»' => ',', '£¿' => '?', '£¡' => '!', '¡­' => '-', '¡¬' => '|',
    '¡±' => '"', ''' => '`', '¡®' => '`', '£u' => '|', '¡¨' => '"',
    '¡¡' => ' ');
    return strtr($str, $arr);
    }

È«½ÇÓe°e½ÇÖ®Çø±ð£¨À´×ÔÖÐÎÄά»u°Ù¿Æ£(C)

È«½Ç£¬ÓÖ³ÆÈ«ÐΡ¢È«¿i£¬ÊǵçÄÔ×ÖuµÄÒ»ÖÖ¸ñʽ£¬×ÖÃaeÒa˼ÊDZÈÆÕͨ×Öu£¨»o°e½Ç×Öu£(C)¿iµÄ×Öu¡£

´«Í³ÉÏ£¬Ó¢Ói»oÀ­¶¡×ÖĸÓiÑÔʹÓÃÒ»×ֽڵĿռaÀ´´ae´¢£¬¶øºº×Ö¡¢ÈÕÓiµÈ³£Ê¹ÓÃÁ½×Ö½Ú´ae´¢£¬ÔÚʹÓù̶¨¿i¶ÈÎÄ×ֵĵؽ£¬ÎªÁËʹ×ÖÌa¿´ÆðÀ´ÕuÆe£¬Ó¢ÎÄ×Öĸ¡¢Êý×Ö¼°ÆaËuuºÅ£¬Ò²ÓÉÔ­À´Ö»Õ¼ÓÃÒ»¸o×Ö¿Õ¼a£¬¸ÄΪһ¸ÅÕ¼ÓÃÁ½¸o×ֵĿռaÀ´ÏÔʾ£¬²¢ÇÒʹÓÃÁ½¸o×Ö½ÚÀ´´ae´¢¡£

ÒÔÉÏËuÊo¾ÍÊDZ¾ÎĵÄÈ«²¿ÄÚÈÝÁË£¬Ï£Íu´o¼ÒÄܹ»Ï²»¶¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例