使用android应用程序从mysql数据库中选择阿拉伯语单词

时间:2016-04-05 20:48:36

标签: android utf-8 arabic genymotion

我有一个Android应用程序,我已将其连接到mysql数据库
数据库包含阿拉伯语单词,当我从数据库中选择这些单词时,阿拉伯语单词将被衰减,如图所示

enter image description here


结果必须像这样

sho = فەفف
hawkar= Array
nechir= Array
test= Array

如下图所示,我的数据库的校对是utf8_general_ci,如下所示阿拉伯语单词在表格中没有任何问题
enter image description here


这是背景作品的代码

protected String doInBackground(String... params) {

    String login_url="http://kurddic.site88.net/login2.php";

    String method=params[0];
    if(method.equals("register")){

    }
    else if(method.equals("login")){

        try {
            URL url=new URL(login_url);
            HttpURLConnection httpURLConnection=(HttpURLConnection)url.openConnection();
            httpURLConnection.setRequestMethod("POST");
            httpURLConnection.setDoInput(true);
            httpURLConnection.setDoOutput(true);

            InputStream inputStream=httpURLConnection.getInputStream();

            BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));

            String response="";
            String line="";

            while ((line=bufferedReader.readLine())!=null) {
                response+=line;
            }

            bufferedReader.close();
            inputStream.close();
            httpURLConnection.disconnect();
            return response;

        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }


这是php选择代码

<?php
require "config.php";
$sql_query = "select en,ku from words where active='1'";
$result=mysql_query($sql_query);
if($qq=mysql_num_rows($result)>0){
while($row=mysql_fetch_assoc($result)){
$name=$row["en"];
$name2=$row["ku"];
echo $name."= ".$name2;
echo"<br/>";
}

}
else{
echo "no info is available";
}
?>


请注意,iam使用Genymotion模拟器
问题是我的模拟器还是什么?

感谢您的帮助......

1 个答案:

答案 0 :(得分:1)

修改您的代码

BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));