此函数是PHP中哪方面的常识,其功能是何

WBOY
Release: 2016-06-13 13:07:12
Original
761 people have browsed it

此函数是PHP中哪方面的知识,其功能是何?
洒家偶遇如下一函数,从未接触过。
第一,是PHP中哪方面的知识?文件处理吗?还是二进制?
第二,请从头到末注解一番。为何要用过00XX,内存码。

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->function js_unescape($str)    
{    
    $ret = '';    
    $len = strlen($str);    
    for ($i = 0; $i >6)).chr(0x80|($val&0x3f));    
            else $ret .= chr(0xe0|($val>>12)).chr(0x80|(($val>>6)&0x3f)).chr(0x80|($val&0x3f));    
            $i += 5;    
        }    
        else if ($str[$i] == '%')    
        {    
            $ret .= urldecode(substr($str, $i, 3));    
            $i += 2;    
        }    
        else $ret .= $str[$i];    
    }    
    return $ret;    
}  
Copy after login


------解决方案--------------------
解码,算是php版的unescape(js)
js中escape方法返回一个包含了charstring内容的字符串值(Unicode格式)所有空格、标点、重音符号以
及其他非ASCII字符都用%xx编码代替,其中xx等于表示该字符的十六进制数。例如,空格返回的是"%20"
字符值大于255的以%uxxxx格式存储。
大于0x7f是汉字,高位为1,按位操作,最核心操作就是对汉字解码
0x800我也没看懂,及向右平移6位与或非就出来个东西,是得专门想想啊,谁能给详解一个汉字的编码操作啊

------解决方案--------------------

ucs-2
4e2d
01001110 00101101

utf-8
e4b8ad
11100100 10111000 10101101


to franzhong
既然你知道大于0x7f是汉字,那么怎就不知道小于0x800的就不是汉字
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!