0

When I run the java code I can print 'Sinhala' Unicode using java slf4j logger. But when I run java program on local tomcat server, I cannot print Sinhala Unicode correctly. I tried various ways using UTF-8 decoding. But I'm still struggling with this problem.

As an example.

String word = "වැළදීම";
logger.info(word);

Output of simple java program: වැළදීම
Output when local tomcat up: ව�ළදීම

I added UTF-8 encoding to the catalina.bat file. But the problem is still in the code. If anyone knows the answer. Please help me.

  • That is UTF-8 output (=correct logging), but read as some ISO encoding. If the log in in a file, view it in an editor with the right encoding. On the console, especially under Windows you have only that single byte encoding. In a linux console search for setting the tomcat user locale to an UTF-8 one. – Joop Eggen Oct 26 '17 at 18:50
  • I'm using windows and what should I do for fix this problem? – Wiranji Dinelka Oct 27 '17 at 00:56
  • The Windows console uses the system's encoding, like Cp1252. There are some solutions, https://stackoverflow.com/questions/14109024/how-to-make-unicode-charset-in-cmd-exe-by-default but logging to a file is best. And then you can view it in for instance NotePad++ in UTF-8. – Joop Eggen Oct 27 '17 at 06:32

0 Answers0