I'm trying to receive a JSON Response from a webservice using GuzzleHttp Client but I'm unable to decode the received json data with json_decode which returns null.
I noticed that on the response headers the Content-Type
is application/json; charset=windows-1253
If I convert the json string using iconv from windows-1253 to utf-8 it decodes OK.
So my question is how can I reliably determine which charset the response uses in order to convert correctly and then parse it with json_decode
?
For example a function
getCharsetFromResponse(\GuzzleHttp\Psr7\Response $response){
//detect charset here
.....
return $charset;
}