更新时间:2023-01-04 23:24:27
在PHP的code只是改变了低于线
$字符串= html_entity_de code($教育[$ i] ['comparision_name'],ENT_QUOTES,UTF-8);
$内容=<教育的id ='。$教育[$ i] ['身份证']'。>中$字符串< /教育>。
到
$字符串= $ webservice-> unhtmlspecialchars($教育[$ i] ['comparision_name']);
$内容=<教育的id ='。$教育[$ i] ['身份证']'。>中$字符串< /教育>。
请参阅 用htmlspecialchars
&害羞;的文件 。
I am developing an application in which I am getting data from web service and displaying in the Android mobile. But the problem is while getting Turkish data it is not displaying correctly.
I already set utf-8
in PHP. But still getting special character symbols like A?ık ?ğ
for the string Açık Öğretim
.
Here is my PHP code:
<?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;
?>
And my Java code is / Here I am writing java code just for testing:
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();
}
}
}
And returning XML from web service is:
<?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>
In the Php code just change the below lines
$string = html_entity_decode($education[$i]['comparision_name'], ENT_QUOTES, "utf-8");
$content.="<education id='".$education[$i]['id']."'>".$string."</education>";
to
$string = $webservice->unhtmlspecialchars($education[$i]['comparision_name']);
$content.="<education id='".$education[$i]['id']."'>".$string."</education>";