Reputation: 9134
I have a problem with the accent character in different platforms.
When I log this in my machine under fedora (where default charset is UTF-8) it is printing correvtly as Sacré Coeur.
But when i update to another server that is running on RedHat (where default charset is ISO-8859-1), it is printing as
Sacré Coeur.
I want to log it in RedHat server as same as in my my Fedora machine. How can I do this?
My Workout :
I tried this one as well but not working.
System.setProperty("file.encoding","ISO-8859-1");
Field charset =Charset.class.getDeclaredField("defaultCharset");
charset.setAccessible(true);
charset.set(null,null);
Upvotes: 0
Views: 428
Reputation: 2703
To get similar out put from all the environments, with out depending on the server OS default character encoding, when you start your program or the server environment (Jboss tomcat or jetty) pass -Dfile.encoding to the start-up script
(lets say run.sh in jboss, add -Dfile.encoding=UTF-8 to JAVA_OPTS)
-Dfile.encoding=UTF-8
Upvotes: 1