Arabic text did not show Json Android when using 3g

旧巷老猫 提交于 2021-01-29 18:29:23

问题


when I use this link to get date and day in Arabic language (utf-8) http://iraqispring.com/apps/get_date_time.php

it is work without problems when I use wifi but when I use 3g it is get me like this text الاثنين 2015-01-12

I am using Volley library and this is the code

RequestQueue queuedate = Volley.newRequestQueue(this);
String url ="http://iraqispring.com/apps/get_date_time.php";
StringRequest stringRequestDate = new StringRequest(Request.Method.GET, url,
        new Response.Listener() {
            @Override
            public void onResponse(Object o) {
                String dateStr = o.toString();
                dateStr.getBytes();
                txtDate.setText(dateStr);
            }
        }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        Toast.makeText(context,"not worked 3",Toast.LENGTH_LONG).show();
    }
});

what can I do?


回答1:


While sending such kind of special characters to server you need to encode such input with the help of URLEncoder.encode(your_input, "utf-8") and while receiving such kind of data first of all you need to decode it with the help of URLDecoder.decode(your_data, "utf-8")

I have also faced such kind of problem, so I followed encoding and decoding and resolved the problem. I think this will help you too.



来源:https://stackoverflow.com/questions/27902623/arabic-text-did-not-show-json-android-when-using-3g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!