2

I have a Java RESTlet v2.1.2 method like this:

@Post("json") 
public Representation doPost(Representation entity) throws UnsupportedEncodingException { 
  Request request = getRequest(); 
  String entityAsText = request.getEntityAsText(); 
  logger.info("entityAsText = " + entityAsText + " Üüÿê");

in the Cygwin console it prints:

2015-04-19 22:07:27 INFO  BaseResource:46 - entityAsText = { 
"Id":"xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx", 
"Field1":"John?????????", 
"Field2":"Johnson??????????"
} ▄³ Û

As you can see the Üüÿê is printed as ▄³ Û. The characters Üüÿê are also in the POST body of SOAP UI. But they're printed as ???. I have an implemantation which does not use RESTlet where this works. So the settings in SOAP UI are not the problem. (The POST body is in Application/JSON btw.)

How can I extract the unicode chars Üüÿê from the POST body without getting them as ??? ?

1 Answers1

0

I made a test and it works for me but perhaps I don't have same configuration regarding charset / encoding. I used a standalone Restlet application (no servlet) from Postman. Can you give us more details about the version of Restlet and the different editions / extensions you use (for example, Jackson, Servlet, ...)?

Here is what I have for Java (you can have a look at this link: How to Find the Default Charset/Encoding in Java?):

Default Charset=UTF-8
file.encoding=Latin-1
Default Charset=UTF-8
Default Charset in Use=UTF8

You can also specify the charset you sent for your content at the level of the header Content-Type: application/json;charset=utf-8.

I wrote a post some years ago about such issues when using a servlet container. Perhaps could you also find out some hints to help you: https://templth.wordpress.com/2011/06/05/does-your-java-based-web-applications-really-support-utf8/.

Hope it helps you, Thierry

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360