Search code examples
javacharacter-encodingwebsphere-libertyopen-liberty

Strange character encoding


I have a project that runs on WebSphere Liberty on Linux. My language is brazilian portuguese and we have some accented words. My java code sets some user messages like below:

...
ErroResponse erroResponse = new ErroResponse();
erroResponse.setMensagem("Esse grupo não pode ser criado. Já existe um grupo criado com esse nome.");
response = Response.status(Status.BAD_REQUEST).entity(erroResponse).build();
...

When the same message is show to the user, it looks this way: enter image description here

I don't think it's a browser encoding problem because the message looks the same on my server logs. enter image description here

I've tried to set JVM encoding using -Dclient.encoding.override -Dfile.encoding to ISO-8859-1 and UTF-8, without success.

The same project, running on a Windows server, runs without problem, showing the messages with the correct accents.

Only message that were directly written in the source code has this problem. Accented words that came from database query result are correctly presented.

I'm using Suse 11.4.

I really appreciate any help.

Thanks


Solution

  • The problem was solved changing the project text encoding. By default eclipse was saving the source code as UTF-8 and javac was compiling it as CP1252 (Windows Default).

    To make this change I had to right click on Project -> Properties -> Resource then changed Text file encoding to Other (ISO-8859-1).