0
String japanText = "\u65e5\u672C\u8A9E";
PrintStream out = new PrintStream(System.out,true,"UTF-8");
out.println(japanText);

See this code execute on IdeOne.com.

This Java code gives Japanese text in ConEmu console, but not working in classic win10 cmd and Powershell as well. Is there any way to make it work? enter image description here

enter image description here

p.s. have changed chcp 65001

tegowai
  • 81
  • 1
  • 1
  • 8
  • Maybe tth Font for the letters is missing to be installed on Windows. – Simulant Jan 23 '22 at 16:25
  • 2
    Does this SO question (and answer) help? [Displaying Unicode in Powershell](https://stackoverflow.com/questions/49476326/displaying-unicode-in-powershell) – Abra Jan 23 '22 at 16:53
  • This isn’t just a Java issue. Try copying Japanese characters from the Windows Character Map and pasting them in a command window, and you’ll see the same behavior. – VGR Jan 23 '22 at 18:07
  • 1
    The default font used for console windows is [Consolas](https://learn.microsoft.com/en-us/typography/font-list/consolas) since Windows 8 which does not support Japanese characters as it can be seen on looking of the list of supported characters sets in the referenced Microsoft documentation page. So even the usage of UTF-8 character encoding does not result in getting the Japanese characters displayed correct using the default font __Consolas__. – Mofi Jan 24 '22 at 18:06
  • 1
    It would be possible to use the [Windows console API functions](https://learn.microsoft.com/en-us/windows/console/console-functions) in your Java program like `GetCurrentConsoleFontEx` and `GetConsoleOutputCP` to get the currently used font and output code page, remember both in your Java program, use `SetCurrentConsoleFontEx` and `SetConsoleOutputCP` suitable to display Japanese characters in the console window, and finally before exiting use once again `SetCurrentConsoleFontEx` and `SetConsoleOutputCP` to restore original font and output code page. – Mofi Jan 24 '22 at 18:13

0 Answers0