日期:2013-07-15  浏览次数:20502 次

在PHP从AJAX的来的数据进行转化函数

function utf8RawUrlDecode ($source) {
    
$decodedStr = ""
;
    
$pos = 0
;
    
$len = strlen ($source
);
     while (
$pos < $len
) {
        
$charAt = substr ($source, $pos, 1
);
         if (
$charAt == '%'
) {
            
$pos
++;
            
$charAt = substr ($source, $pos, 1
);
             if (
$charAt == 'u'
) {
                
// we got a unicode character
                
$pos
++;
                
$unicodeHexVal = substr ($source, $pos, 4
);
                
$unicode = hexdec ($unicodeHexVal
);
                
$entity = "&#". $unicode . ';'
;