I have created a java program (REST) service. The whole development / testing was done on Windows, now the deployment to production-test is in work. However, there is "small" encoding problem occurred:
String s3 = new String("grün".getBytes(), "UTF-8");
logger.info(s3);
logger.info("das ist wirklich grün");
logger.info(new String("das ist wirklich grün".getBytes("UTF-8"), "UTF-8"));
I receive through HTTP-attributes (the web application is hosted on tomcat, behind an apache which has an auth plugin) a few values I have to process. They are coded like you see in line 1. (This value is shown on both Windows and Linux).
When I convert it to UTF-8 like in line 1 and write it to the log-file (log4j) I have the term "grün" (which is correct) on my Windows machine. On the linux server I still have the same output.
Then I tried to directly use Umlaute (üäö etc), like in line 2, and both on Windows and Linux the value is written correct into the log-file. I then tried to do some convert like in line 3, however, the same result: both operating systems show the same result.
Both machines have the same Locale in Java (Locale.getDefault()) -> I tried that already. I'm not able to change the way the value is inserted into the HTTP-Request!