0

I need to convert the data retrived from api Facebook to ISO-8859-1 in php.

This is an example of output of the api facebook (look to description value) I look that the php api facebook used this method

protected static function base64UrlDecode($input) {
    return base64_decode(strtr($input, '-_', '+/'));
  }

{
   "id": "108012702561007",
   "name": "Sud Sound System",
   "link": "http://www.facebook.com/pages/Sud-Sound-System/108012702561007",
   "likes": 24904,
   "category": "Musician/band",
   "website": "http://www.sudsoundsystem.eu",
   "is_community_page": true,
   "description": "\u003cp>I \u003cb>Sud Sound System\u003c/b>",
   "parking": {
      "street": 0,
      "lot": 0,
      "valet": 0
   },
}
Dany
  • 2,290
  • 8
  • 35
  • 56

1 Answers1

0

JSON defines that escaping syntax as an alternative to Unicode UTF-8 encoding.

A solution was suggested here: How to decode Unicode escape sequences like "\u00ed" to proper UTF-8 encoded characters?

An explanation about that UTF-8 escaping format can be found here: JSON character encoding - is UTF-8 well-supported by browsers or should I use numeric escape sequences? (which points to the RFC: http://www.ietf.org/rfc/rfc4627.txt).

In your case, you'll need to transform from UTF-8 to ISO-8859-1 afterwards (though imho you'd be better off using UTF-8 all along).

Community
  • 1
  • 1
jjmontes
  • 24,679
  • 4
  • 39
  • 51