fql query character encoding

2019-09-20 06:53发布

问题:

I am executing a FQL query, and if I print the array with the results I get wrong characters.

For example instead of ò I get ò.

my webpage is set to: text/html; charset=ISO-8859-1

I think it's an issue with facebook and not with me.. Have you experienced something similar and did you manage to solve it?

回答1:

The results from Facebook are in UTF-8 encoding.

ò character is c3b2 in UTF-8 (hex) 0xC3 - Ã 0xB2 - ²

To convert the results to ISO-8859-1 from UTF-8 in PHP you may use utf8_decode function:

$source = chr(0xc3).chr(0xb2);
$result = utf8_decode($source); // -> 0xF2 (ò in ISO-8859-1)