text formattation of "description" array variable in graph protocol
On the website I am developing, I'm using a function that get information about events taken from a group on facebook. I noticed that using the graph protoc开发者_如何学编程ol, the text contained in the "description" of the created array , there are strange characters like "\ u00b" or "\ n" for new lines. How can I do to display the content formatted correctly? thanks in advance Piero
It is called unicode_decode
( http://webarto.com/83/php-unicode_decode-5.3 ), it will come out in PHP6 until then...
function unicode_decode($string) {
$string = preg_replace_callback('#\\\\u([0-9a-f]{4})#ism',
create_function('$matches', 'return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UCS-2BE");'),
$string);
return $string;
}
Raska Top\u010dagi\u0107 Raska Topčagić
If you are not using PHP, sorry...
Better solution:
echo json_decode('Raska Top\u010dagi\u0107'); # Raska Topčagić
精彩评论