Skip to content

Commit 6371c68

Browse files
committed
1 parent d3b52ee commit 6371c68

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

library/src/com/loopj/android/http/AsyncHttpResponseHandler.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ public class AsyncHttpResponseHandler {
7474
protected static final int FINISH_MESSAGE = 3;
7575

7676
private Handler handler;
77+
private String responseCharset = "UTF-8";
78+
79+
/**
80+
* Sets the charset for the response string. If not set, the default is UTF-8.
81+
* @see <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html">Charset</a>
82+
*
83+
* @param charset to be used for the response string.
84+
*/
85+
public void setCharset(final String charset) {
86+
this.responseCharset = charset;
87+
}
7788

7889
/**
7990
* Creates a new AsyncHttpResponseHandler
@@ -249,7 +260,7 @@ protected void sendResponseMessage(HttpResponse response) {
249260
HttpEntity temp = response.getEntity();
250261
if (temp != null) {
251262
entity = new BufferedHttpEntity(temp);
252-
responseBody = EntityUtils.toString(entity, "UTF-8");
263+
responseBody = EntityUtils.toString(entity, responseCharset);
253264
}
254265
} catch (IOException e) {
255266
sendFailureMessage(e, (String) null);

0 commit comments

Comments
 (0)