2015/04/25

MultipartEntityBuilder and Charset

日本語化けになっている。。
 
 
entity.addTextBody("plain_text", plain_text);
will use the default ContentType.TEXT_PLAIN which look like this...
public static final ContentType TEXT_PLAIN = ContentType.create("text/plain", Consts.ISO_8859_1);

while ContentType.APPLICATION_JSON is using UTF-8 as below
public static final ContentType APPLICATION_JSON = ContentType.create("application/json", Consts.UTF_8);

So what i did was create our own ContentType like this..
entity.addTextBody("plain_text", plain_text, ContentType.create("text/plain", MIME.UTF8_CHARSET));