2009-08-03 41 views

回答

6

發現以下功能的工作原理:

function utf8_urldecode($str) { 

    $str = str_replace("\\00", "%u00", $str); 

    $str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str)); 

    return html_entity_decode($str,null,'UTF-8'); 

} 

某些地區的http://us2.php.net/manual/en/function.urldecode.php

+0

**警告:**此功能將無效代碼點。 – hakre 2012-05-11 20:38:55

0

試試這個:

function masked_utf16_to_utf8($str) { 
    $str = preg_replace_callback('/\\\\([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/', create_function('$match', 'return mb_convert_encoding(chr(hexdec("$match[1]")).chr(hexdec("$match[2]")), "UTF-8", "UTF-16");'); 
    return $str; 
} 
+0

這似乎不適用於我 – Maarten 2009-09-17 07:12:17

相關問題