Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-byte character got garbled on received mail. #6

Closed
kikutaro opened this issue Jul 11, 2016 · 2 comments
Closed

Multi-byte character got garbled on received mail. #6

kikutaro opened this issue Jul 11, 2016 · 2 comments
Labels
status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library

Comments

@kikutaro
Copy link
Contributor

Issue Summary

When I was sending mail with Japanese multi-byte character via sendgrid-java v3.0.2, the received mail contents got garbled.Ex. こんにちは -> ?????

capture2

Pretty similar #4 but this is not sending but receiving.

Steps to Reproduce

Following simple code.

SendGrid sg = new SendGrid("api keys");
Request request = new Request();
Email from = new Email("from@from.co.jp");
String subject = "こんにちは";
Email to = new Email("to@to.co.jp");
Content content = new Content("text/plain", "こんにちは");
Mail mail = new Mail(from, subject, to, content);

request.method = Method.POST;
request.endpoint = "mail/send";
request.body = mail.build();
Response response = sg.api(request);

I tried curl command with multi-byte, it worked fine. The result means issue on library side.

Technical details:

  • java-http-client Version: 2.3.1
  • sendgrid-java Version:3.0.2
  • Java Version: JDK 8u66
@kikutaro
Copy link
Contributor Author

@thinkingserious I checkd the code both sendgrid-java and java-http-client.
I think the response also needs Charset UTF-8 like following.

-- responseBody = handler.handleResponse(response);
++ responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);

I tried this on my fork code, and it worked.
solve
This caused by the default encoding is ISO-8859-1 of HttpClient's Response Body.
http://hc.apache.org/httpclient-3.x/charencodings.html

kikutaro added a commit to kikutaro/java-http-client that referenced this issue Jul 11, 2016
@thinkingserious thinkingserious added type: bug bug in the library status: help wanted requesting help from the community status: work in progress Twilio or the community is in the process of implementing and removed status: help wanted requesting help from the community labels Jul 11, 2016
@thinkingserious
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library
Projects
None yet
Development

No branches or pull requests

2 participants