首页 > 代码库 > 网络操作-转码(乱码情况处理)

网络操作-转码(乱码情况处理)

在请求对象里面添加下面一条语句:

protected Response<String> parseNetworkResponse(NetworkResponse response) {                try {                    String jsonObject = new String(                            new String(response.data, "UTF-8"));                    return Response.success(jsonObject, HttpHeaderParser.parseCacheHeaders(response));                } catch (UnsupportedEncodingException e) {                    return Response.error(new ParseError(e));                } catch (Exception je) {                    return Response.error(new ParseError(je));                }            }

 

网络操作-转码(乱码情况处理)