UTF-8 encoding in Volley Requests

后端 未结 8 1474
天命终不由人
天命终不由人 2020-12-06 02:17

In my Android app I am loading json data with a Volley JsonArrayRequest. The data were created by myself and I saved them with Sublime with UTF-8 encoding. When

相关标签:
8条回答
  • 2020-12-06 02:50

    This is worked as a charm for me,, I just created a static method from @Muhammad Naeem's answer,, Thanks Muhammed..

    public static String fixEncodingUnicode(String response) {
        String str = "";
        try {
            str = new String(response.getBytes("ISO-8859-1"), "UTF-8");
        } catch (UnsupportedEncodingException e) {
    
            e.printStackTrace();
        }
    
        String decodedStr = Html.fromHtml(str).toString();
        return  decodedStr;
    }
    
    0 讨论(0)
  • 2020-12-06 02:51

    To specify in server part set utf-8 in content type like "text/html;charset=utf-8"

    0 讨论(0)
提交回复
热议问题