About the problem and solution of Chinese garbled when downloading windows code to Mac

the reason

Windows

Windows is GBK coded in China. GB2312 is an earlier national standard, and it has been used in the early windows system. GBK is an expansion solution compatible with GB2312. GB18030 also appeared in the later period. Later, in order to use GBK, it is also for compatibility.

Mac

The alias of Unicode is the universal code. Through this name, it can be seen that this is a cross-language, cross-platform encoding, and it is now more widely used. But although Unicode was released earlier, at that time windows had begun to support GB2312 kkk. The Mac system uses Unicode extensively, so it conflicts with Windows in Chinese encoding.

solution

VS Code

1. Click UTF-8 to select the appropriate encoding
Insert picture description here
2. Select Reopen with Encoding
Insert picture description here
3. Select any encoding of the GB system
Insert picture description here
4. The encoding conversion is successful
Insert picture description here

Sublime text

Reference link: Solve the problem of Chinese garbled characters in Sublime Text2 or 3 under Mac os.
Open Sublime Text and Insert picture description here
Sublime Text has installed package control (refer to the above link if it is not installed), enter Command+shift+p,
Package Control interface
enter Install Package,
Insert picture description here
press Enter and select ConvertToUTF8 (It seems that GBK Support is also valid.)
ConvertToUTF8
GBK Support
Choosing ConvertToUTF8 will remind you to install Codecs33
Insert picture description here
. Enter Codecs33 in Install Package to install
Insert picture description here
and then reinstall ConvertToUTF8 (if it is not in Install Package, the installation is successful), restart Sublime text, and wait a while (requires Load package), you will find that the Chinese is normal.
Insert picture description here
Compared with vs code, you need to manually modify the encoding every time you open the file. Sublime does not need to manually adjust the encoding after installing the package.

Documentation

There will be no garbled characters when opening the document directly.
Insert picture description here
Code source:
JAVA application design

Guess you like

Origin blog.csdn.net/Cindy_00/article/details/107121886