Issue
I have a problem with encoding strings in RESTeasy. The problem is that chinese alphabet or any other non-latin characters are not displayed properly. If I try to print them out (or send as response) I get "?????" instead. I believe that default encoding in RESTeasy is us-ascii. Do you know how to change it to UTF-8? Maybe there is another solution to this problem?
Here is a short passage from my code:
@POST
@Path("post")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String uploadData(@MultipartForm DataUploadForm uploadForm) {
...
//the code below is just for the purpose of presentation
String text = "some non-latin alphabet signs here"
System.out.println(text); // "??????" is printed out
return text; //"??????" is returned
}
My resteasy-jaxrs-3.0-beta-2 is running on Tomcat 7.0.
Thank you!
Solution
This is not about resteasy or jax-rs mate.
Check this post
There are several things you may want to look into:
- If the data is from DB, then you need to make sure data in DB it is encoded correctly.
- Your JVM environment is encoding using utf8
- It could be an issue of IDE, because IDE and your tomcat might running on different configurations.
Answered By - Xiangyu
Answer Checked By - Senaida (JavaFixing Volunteer)