table of Contents
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
2. Select Reopen with Encoding
3. Select any encoding of the GB system
4. The encoding conversion is successful
Sublime text
Reference link: Solve the problem of Chinese garbled characters in Sublime Text2 or 3 under Mac os.
Open Sublime Text and
Sublime Text has installed package control (refer to the above link if it is not installed), enter Command+shift+p,
enter Install Package,
press Enter and select ConvertToUTF8 (It seems that GBK Support is also valid.)
Choosing ConvertToUTF8 will remind you to install Codecs33
. Enter Codecs33 in Install Package to install
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.
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.
Code source:
JAVA application design