0

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

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.

Omji Mehrotra
  • 254
  • 1
  • 7
  • If server has encoded data then @Override public void onResponse(Object o) { String dateStr = o.toString(); try { dateStr = URLDecoder.decode(dateStr, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } dateStr.getBytes(); txtDate.setText(dateStr); } try this and please let me know. – Omji Mehrotra Jan 14 '15 at 06:09