0

In my application, I'm reading the properties file(UTF-8 encoded) containing Chinese characters and printing them on the Windows command line. But,for some reason the the messages are not getting displayed correctly(some extra characters are coming). However the same mesages are getting displayed correctly on Eclipse console and Cygwin. I've set the command line code page to utf-8(65001) and used "Lucida" font as well.

enter image description here

If you see the above image, on Windows it printed one extra 0 on the second line, but that is not expected;on cygwin the message was printed correctly.

Please let me know if I'm missing something. From this post , I can see that there are some issues with Windows UTF-8 code page implementation. If so, is there any other way to get over this problem ?

Community
  • 1
  • 1
geekprogrammer
  • 1,108
  • 1
  • 13
  • 39

1 Answers1

1

I can see that there are some issues with Windows UTF-8 code page implementation

oh most surely yes

is there any other way to get over this problem ?

The typical solution is to accept that the Windows command prompt is a broken disaster and move on. But if you really have to, you can use JNA to call the Win32 function WriteConsole directly, avoiding the broken byte encoding layer, when you can determine you are outputting to the console (rather than eg a pipe).

bobince
  • 528,062
  • 107
  • 651
  • 834
  • Thanks for your answer. I've converted my properties file using native2ascii tool provided by JDK and the messages were printed correctly. It seems that Windows doesn't have any problem convertng andn printing the escaped unicode characters(native2ascii tool conveted Chinese characters to escaped unicode characters). – geekprogrammer Oct 25 '15 at 07:39