php 乱码 iconv('UCS-2'



iconvlib是由系统提供的。
UCS-2编码一般默认是大头,今天在一台机器上居然是小头(CentOS xeon64),最后统统把UCS-2改成UCS-2BE。
有兴趣试试下面的PHP代码:
echo iconv('UCS-2', 'gbk', pack('H4','8F66'));
echo iconv('UCS-2LE', 'gbk', pack('H4', '8F66'));
echo iconv('UCS-2BE', 'gbk', pack('H4', '8F66'));
在centos某些机器上默认ucs-2即ucs-2LE。
iconv.c:197:names for UCS-2LE: UCS-2LE


iconv.c:197:names for UCS-2BE: UCS-2BE


debian  为  UCS-2BE


 $v ) {  
        if (iconv_substr ( $v, 0, 2 ) == '%u')  
            $ar [$k] = iconv ( 'UCS-2BE', 'gbk', pack ( 'H4', iconv_substr ( $v, - 4,4 ) ) );  
        elseif (substr ( $v, 0, 3 ) == '&#x')  
            $ar [$k] = iconv ( 'UCS-2BE', 'gbk', pack ( 'H4', substr ( $v, 3, - 1 ) ) );  
        elseif (substr ( $v, 0, 2 ) == '&#') {  
            $ar [$k] = iconv ( 'UCS-2BE', 'gbk', pack ( 'n', substr ( $v, 2, - 1 ) ) );  
        }  
    }  
    return join ( '', $ar );  
} 
$now_time=date("Y-m-d H:i:s");
echo $now_time.'
时尚欣欣65
解码之后:'; echo phpunescape('%u65F6%u5C1A%u6B23%u6B2365'); //echo curlGetRurl('http://iframe.ip138.com/ic.asp',10); ?>


你可能感兴趣的:(php 乱码 iconv('UCS-2')