The character is UTF8 encoded, like..
"\u676f\u845b"
How to convert it back to normal UTF8 string in PHP?
The character is UTF8 encoded, like..
"\u676f\u845b"
How to convert it back to normal UTF8 string in PHP?
The simple approach would be to wrap your string into double quotes and let json_decode
convert the \u0000
escapes. (Which happen to be Javascript string syntax.)
$str = json_decode("\"$str\"");
Seems to be asian letters: 杯葛
(It's already UTF-8 when json_decode
returns it.)
(Source)
http://webarto.com/83/php-unicode_decode-5.3 demo: http://ideone.com/AtY0v
function decode_encoded_utf8($string){
return preg_replace_callback('#\\\\u([0-9a-f]{4})#ism', function($matches) { return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE"); }, $string);
}
echo unicode_decode('\u676f\u845b'); # 杯葛