RadarCZ
RadarCZ

Reputation: 59

cURL returns wrong characters

I have JSON object

{"state1":"http://www.furry.cz/images/spot_public.gif","state2":"http://www.furry.cz/images/spot_readonly.gif","Id":"332","Name":"Co pr%av%e poslouch%ate?","Section":"Hlavn%i","Posts":"5473","Readable":1,"User":"Šroubek","Time":"00:25 23.07.2014","New":0}

on external server and I'm downloading it with cURL

<?php
   $curl = curl_init("http://dagl.6te.net/fcz/api.php?c=forum");
   curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
   curl_setopt($curl, CURLOPT_ENCODING, "");
   $result = curl_exec($curl);

and instead of Šroubek it returns �roubek.

I also tried converting it with iconv, by setting

header("Content-Type: text/html, charset=UTF-8") 

and by

curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: text/plain, charset=UTF-8'));

Upvotes: 0

Views: 533

Answers (1)

Natsu
Natsu

Reputation: 160

Page that you are trying to download data in ANSI your in UTF-8, then there is an error in the encoding. In addition, you gain data from the page dagl.6te.net that downloading a page furry.cz in ANSI and there does not change encoding .. Therefore accented characters Replacin original to further the application to switch back to the characters.

Example: Š = %S in appliaction i change it back to Š

EDIT: Fixed in API.

Upvotes: 1

Related Questions