如何设置httpclient的字符编码

Mur*_*rat 1 android httpclient character-encoding

我正在使用这个httpclient:http://loopj.com/android-async-http/我正在使用这个httpclient 获取json.我想设置这个httpclient的字符enconding.客户端返回的JSONObject包含土耳其字符,例如şğöü.但它已损坏,我无法查看这些字符.

如何设置此httpclient的字符编码?

luj*_*jop 5

正确的是服务器提供返回页面的编码.如果这样做,您将收到正确的.但如果它不提供编码Async-http似乎假设UTF-8并且查看代码它似乎不支持提供默认的替代方法.

AsyncHttpResponseHandler中的相关代码:

// Interface to AsyncHttpRequest
void sendResponseMessage(HttpResponse response) {
    ...
    responseBody = EntityUtils.toString(entity, "UTF-8");
Run Code Online (Sandbox Code Playgroud)

如果您愿意,您需要使用自己的AsyncHttpResponseHandler版本,或建议修补程序能够指定默认编码.