Issue
I have a problem with encoding Java System Output occurring only in Visual Studio Code.
Like you can see in the image below bullet print as ?
Eclipse and IntelliJ print the bullet point just fine.
My program is very simple: href="https://i.stack.imgur.com/3uVc7.png" rel="nofollow noreferrer">
Things I have tried/checked:
I only have the Java Extension Pack by Microsoft installed.
It is a fresh new file created from VScode.
Solution
The UTF-8
displayed in the lower right corner of VS code is the encoding format of the current file, not the encoding format of the terminal.
You should check the encoding by typing chcp
in the terminal of VS code.
The encoding format of the terminal in vscode may be different from the system's cmd and powershell encoding.
So please check the encoding format in the terminal in VS code, not in the cmd or powershell window of the system
Here is my test display:
my code:
public class App {
public static void main(String[] args) {
System.out.println("example ●");
}
}
The encoding format of the system cmd window is 65001
The encoding format of the system powershell window is 65001
But the terminal encoding in vscode is 437
Run the result directly ( Can't display symbols )
So you need to use chcp 65001
to change the current terminal encoding format in VS code.
then run the code ( success display symbol)
But this still has problems, every time you open a new terminal, you need to manually type the command chcp 65001
to change the encoding format.
I found a way in my constant search. Add the following configuration in settings.json:
"terminal.integrated.shellArgs.windows": ["-noexit", "chcp 65001"]
A yellow squiggly line will appear indicating that this configuration is out of date and there are now new configuration commands. Never mind, this still works. If you want to see the new configuration, here.
Note: After adding this configuration, you need to restart VS code to take effect.
In this way, when you create a new terminal, you will automatically use the command chcp 65001
to change the encoding to 65001
Now run the code directly, the symbols can be displayed
Answered By - JialeDu
Answer Checked By - Clifford M. (JavaFixing Volunteer)