Come submit e recuperare dati dal servizio web utilizzando PHP e Android

Sto sviluppando un'applicazione in cui sto ricevendo dati dal servizio web e visualizzati sul cellulare Android. Ma il problema è mentre si ricevono dati turchi che non viene visualizzato correttamente.

Ho già impostato utf-8 in PHP. Ma Açık Öğretim ancora simboli di caratteri speciali come A?ık ?&#287 per la string Açık Öğretim .

Ecco il mio codice PHP:

 <?php include("Netbrut_class.php"); header('Content-type: text/xml; charset: utf-8'); $webservice = new Netbrut; $content='<?xml version="1.0" encoding="utf-8"?><salary_comparision>'; $education = $webservice->select_education(); for($i=0; $i<count($education); $i++){ $string = html_entity_decode($education[$i]['comparision_name'], ENT_QUOTES, "utf-8"); $content.="<education id='".$education[$i]['id']."'>".$string."</education>"; } $content .='</salary_comparision>'; echo $content; ?> 

E il mio codice Java è / Qui sto scrivendo il codice Java solo per i test:

 public class testing { static String[] attributes; public static void main(String[] args) { URL url; try { url = new URL("http://192.168.1.106/netBrut/webservices/testing.php"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection = (HttpURLConnection) url.openConnection(); java.io.InputStream is = connection.getInputStream(); InputStreamReader reader = new InputStreamReader(is, "utf-8"); StringWriter sw = new StringWriter(); char [] buffer = new char[1024 * 8]; int count ; while( (count = reader.read(buffer)) != -1){ sw.write(buffer, 0, count); } System.out.println(sw.toString()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } 

E restituire XML dal servizio web è:

 <?xml version="1.0" encoding="utf-8"?> <salary_comparision> <education id='128'>A?ık ?ğretim</education>//Check here <education id='5'>Doktora</education> <education id='3'>Master</education> <education id='4'>MBA</education> <education id='2'>?niversite</education> </salary_comparision> 

Nel codice Php basta cambiare le linee sottostanti

  $string = html_entity_decode($education[$i]['comparision_name'], ENT_QUOTES, "utf-8"); $content.="<education id='".$education[$i]['id']."'>".$string."</education>"; 

a

 $string = $webservice->unhtmlspecialchars($education[$i]['comparision_name']); $content.="<education id='".$education[$i]['id']."'>".$string."</education>"; 

Vedi i documenti di htmlspecialchars .