Windows 10 CLI UTF-8 encoding

后端 未结 2 1908
情书的邮戳
情书的邮戳 2020-12-10 19:59

Problem:

On an english Windows 10 using slovenian keyboard layout, all command line interfaces seem to have a problem with displaying (printing) UTF-8 characters, n

相关标签:
2条回答
  • 2020-12-10 20:19

    Use chcp 65001 then run with java -Dfile.encoding=UTF-8 Test2:

    chcp 65001
    javac -encoding UTF-8 Test2.java
    java -Dfile.encoding=UTF-8 Test2
    

    Remember to name your Java source file after the class name, case-sensitive.

    0 讨论(0)
  • 2020-12-10 20:34

    After following @Andreas advice, i have further explored the issue and found a fix that works:

    First force cmd to use chcp 65001 (UTF-8) following this link on superuser.

    Secondly use the following command:

    set JAVA_TOOL_OPTIONS =-Dfile.encoding=UTF-8
    
    0 讨论(0)
提交回复
热议问题