I'm having difficulty correctly displaying Special Characters in our PHP application. The Special Characters are being displayed as "?" in most cases. I believe this has to do with the cURL operation.
We store our content in a Content Management System which we return via cURL. When I return our content via CMS, the Special Characters change to �. When I use mb_convert_encoding on these keys, it displays the Special Character as "?". How can I correctly display Special Characters? Any help would be appreciated!
Content Management System:
- Zürich Airport
Result Output - using cURL (Before mb_convert_encoding):
- Z�rich Airport
Page Output (After mb_convert_encoding):
- Z?rich Airport
Code:
$curl = curl_init();
curl_setopt($curl,CURLOPT_HTTPHEADER,array(
'Content-type:application/json'
));
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,json_encode(array(
'contentKeyName' => $prefix,
'langCode' => $language,
'rollSetiForExperiments' => false
)));
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_TIMEOUT,10);
curl_setopt($curl,CURLOPT_URL,$endpoint);
$response = new stdClass();
$response->response = curl_exec($curl);
$response->headers = curl_getinfo($curl);
$response->error_number = curl_errno($curl);
$response->error_message = curl_error($curl);
curl_close($curl);
$result = $response->response; // If I echo $result, Special Characters are outputted as �
$result = mb_convert_encoding($result,'utf-8'); // Changes � to ?
Desired Output:
- Zürich Airport