0

We use

chcp 932 
reg query /?

inside Runtime.exec() in java 64bit eclipse with Locale set to Japanese using

Locale.setDefault()

Text file encoding in Eclipse is set to UTF-8. However, on running said query to get the long/short date time formats, the japanese characters are not displayed properly on the console. (They are printed as:)

sLongDate REG_SZ yyyy'�N'M'��'d'��'

We also do:

System.out.println(new String(cmdOutput.getBytes ("UTF-8")));

It is interesting to note that while running the above in windows cmd, the Japanese characters are displayed correctly (that is, after changing active page code to 932).

What is missing in the above character encoding approach?

[Update]: Changing eclipse IDE font type to MS UI Gothic as mentioned here[What Font to Use to Display Japanese Characters in Eclipse Console Output? displays atleast some of the characters like (Japanese yen). But still, other characters are not printed correctly (like ��)

bespectacled
  • 2,801
  • 4
  • 25
  • 35
  • 2
    could you see if this helps? https://stackoverflow.com/questions/39239033/can-java-change-the-codepage-of-its-own-console – Eugene Aug 16 '17 at 07:54
  • @Eugene thank you! I tried the following: `ArrayList cmds = new ArrayList(); cmds.add("reg"); cmds.add("query"); cmds.add("\"HKCU\\Control Panel\\International\""); cmds.add("/V"); cmds.add("sLongDate"); ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", "chcp", "932").inheritIO().command(cmds); Process p = pb.start(); p.waitFor();` But, this still has issues. What is wrong in the above code? – bespectacled Aug 16 '17 at 10:15

0 Answers0