I'm using GoogleMaps API to retrieve location information. The result is fetched via cURL
and the fetched string should be converted to a JSON-object using json_decode
.
For many locations (in for example The Netherlands) this works like a charm. But for many German (and probably more countries like Austria, Swiss etc) this doesn't work as expected.
I believe this is because of the 'special' characters like ß
, but also ü
, ë
, ä
, ï
and so on.
For example: this is the string fetched via cURL (http://maps.googleapis.com/maps/api/geocode/json?address=Stoltenkampstra%C3%9Fe%2011,Bad%20Bentheim&sensor=false&language=nl)
In the following $sResponse
is the result fetched by cURL
.
When I try to perform json_decode($sResponse);
its value becomes null
. When I perform json_last_error()
it says 5 (which means JSON_ERROR_UTF8). When I perform mb_detect_encoding($sResponse)
it says UTF-8
.
Any suggestions?