UTF-8 encoding in Volley Requests

后端 未结 8 1506
天命终不由人
天命终不由人 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;
    }
    

提交回复
热议问题