问题
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