Solve Chinese garbled characters in IntelliJ IDEA console in 1 minute, set utf-8 uniformly, and no more garbled characters

First address
https://it1314.top/article/776/

4 solutions to Chinese garbled characters in IDEA console, graphic tutorials, Chinese will no longer be garbled

If IntelliJ IDEA does not make relevant settings, it may cause problems such as garbled Chinese characters in the console and garbled Chinese characters in the configuration files, which will greatly affect problem tracking during the coding process. This article summarizes
common solutions to Chinese garbled characters in IDEA, hoping to help everyone.

IDEA Chinese garbled codeIDEA Chinese garbled code

solution

1. Set the font to a font that supports Chinese

Click the menu File -> settings -> appearance and set the font to Microsoft Yahei that supports Chinese :

Set to support Chinese Microsoft Yahei fontSet to support Chinese Microsoft Yahei font

2. Set the character encoding to UTF-8

Click Menu File-> settings-> Eitor-> to set the character global encoding, project encoding, and configuration file encoding to unified , then click Apply to apply the settings, and click File EncodingsOK to close the dialog box:
UTF-8

Note: Transparent native-to-ascii conversionIt needs to be checked, otherwise the Chinese comments in the configuration file in the project will not be displayed normally.

Set characters to UTF-8 that supports ChineseSet characters to UTF-8 that supports Chinese

3. Modify the IDEA configuration file to support Chinese encoding

first way

If after doing the above operations, there are still garbled Chinese characters, you can try the following operations again.

Find the installation directory of IDEA, enter /binthe folder, and find the following two files:

image-20230914103442300
Add file encoding format in IDEA configuration file

Then, add the following configuration to the last line of the two files :

-Dfile.encoding=UTF-8

TIP: The new version of IDEA has only one idea64.exe.vmoptionsfile, just add this file.

Second way

Click "Help→Etit Custom VM Options..." in the upper navigation bar to enter the custom virtual machine options page.

Insert image description here

Insert image description here

Add at the end of the idea64.exe.vmoptions file -Dfile.encoding=UTF-8. After restarting, run the program to check the console information. Generally, the problem will be solved at this step. Of course, if it doesn't work, please perform the following super steps .

Insert image description here

Insert image description here

4. Check whether the bottom of the console is also in UTF-8 encoding format.

If not, it needs to be set to UTF-8:

5. How to solve the garbled output of Tomcat console?

If your project uses an external Tomcat and the console output log is garbled, you can do the following.

Click Run -> Edit Configurations… on the upper navigation bar to enter the configuration page, modify
the virtual machine output option VM options of the current Web project Tomcat Server, and add it-Dfile.encoding=UTF-8
, as shown below:

Let Tomcat support UTF-8 encodingLet Tomcat support UTF-8 encoding

Finally, IDEA must be restarted

After the relevant configuration modifications are completed, you need to restart IDEA for the settings to take effect . Check again to solve the Chinese garbled problem~

Reference article

https://it1314.top/article/776/

Guess you like

Origin blog.csdn.net/JasonXu94/article/details/132871422