php - How to decode Unicode escape sequences like "\u00ed" to proper UTF-8 encoded characters? -


is there function in php can decode unicode escape sequences "\u00ed" "í" , other similar occurrences?

i found similar question here doesn't seem work.

try this:

$str = preg_replace_callback('/\\\\u([0-9a-fa-f]{4})/', function ($match) {     return mb_convert_encoding(pack('h*', $match[1]), 'utf-8', 'ucs-2be'); }, $str); 

in case it's utf-16 based c/c++/java/json-style:

$str = preg_replace_callback('/\\\\u([0-9a-fa-f]{4})/', function ($match) {     return mb_convert_encoding(pack('h*', $match[1]), 'utf-8', 'utf-16be'); }, $str); 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -