简体   繁体   English

如何在 VS Code 的终端中打印越南语?

[英]How can I print Vietnamese in the terminal in VS Code?

This is my code:这是我的代码:

public class Test {
   public static void main(String[] args) {
      System.out.println("Tiếng Việt có dấu");
  }
}

In the VS Code terminal it prints:在 VS Code 终端中打印:

Ti?ng Vi?t có d?u

How can I fix it so the VS Code terminal displays the text correctly?如何修复它以便 VS Code 终端正确显示文本?

Assuming Windows >= 10:假设 Windows >= 10:

  1. 视窗键 + R , intl.cpl , Enter + R , intl.cpl ,输入

  2. doing this:这样做:

  1. Restarting system.重新启动系统。

See here/Thank You!看这里/谢谢!


Then (after Restart) we try this in VS Code:然后(重启后)我们在 VS Code 中尝试这个:

public class Test {
  public static void main(String[] args) throws UnsupportedEncodingException {
    System.out.println("1: Tiếng Việt có dấu");
    try ( PrintWriter consoleOut = new PrintWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8))) {
      consoleOut.println("2: Tiếng Việt có dấu");
    }
  }
}

See also/Thank You!另见/谢谢!

(Ensuring): (确保):

VS-Code,文件编码,UTF-8

See Also .另请参阅


... we get (Run Java, default shell, pwsh.7.2.0 in my case): ...我们得到(在我的情况下运行 Java,默认 shell,pwsh.7.2.0):

PowerShell 7.2.0
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS C:\DEV\projects\test>  & 'C:\Program Files\Java\jdk1.8.0_311\bin\java.exe' '-cp' 'C:\Users\xerx\AppData\Local\Temp\cp_16pw9c0xw9lhctexolmzuqrp.jar' 'Test' 
1: Ti?ng Vi?t c d?u
2: Tiếng Việt có dấu
PS C:\DEV\projects\test> 

... but also switching to cmd.exe : ...但也切换到cmd.exe

Microsoft Windows [Version 10.0.19044.1348]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\DEV\projects\test>java -cp C:\Users\xerx\AppData\Local\Temp\cp_16pw9c0xw9lhctexolmzuqrp.jar Test 
1: Ti?ng Vi?t c d?u
2: Tiếng Việt có dấu

GitBash??: - "Null Problemo": GitBash??:-“空问题”:

picard@enterprise MINGW64 /c/DEV/projects/test (main)
$ java -cp ~/AppData/Local/Temp/cp_16pw9c0xw9lhctexolmzuqrp.jar Test
1: Ti?ng Vi?t c d?u
2: Tiếng Việt có dấu

So the problem is rather not in VS Code or Java, but more "general"/historic/"proprietary" (see the threads linked + What encoding/code page is cmd.exe using? + https://www.google.com/search?q=windows+console+encoding :)所以问题不在于 VS Code 或 Java,而是更“通用”/历史/“专有”(请参阅链接的线程 + cmd.exe使用什么编码/代码页? /search?q=windows+console+编码:)

Because in Ubuntu ( wsl ) Shell:因为在 Ubuntu ( wsl ) Shell 中:

picard@enterprise:/mnt/c/DEV/projects/test$ java -cp ./build/classes/java/main/ Test
1: Tiếng Việt có dấu
2: Tiếng Việt có dấu

!! !! ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM