Today, I opened my previous project and wanted to see the code I wrote. After opening the project, I found that the comments of the previous Java source file were garbled. So I searched Baidu and got the conclusion: the cause of the problem: Because the default encoding in Windows is GBK, Ubuntu is the UTF-8, so in Windows under the annotation, Ubuntu becomes garbled. There are two solutions: 1. Change the Ubuntu system encoding to GBK, which is consistent with the Windows encoding, but I cannot use this method.
Today, I opened my previous project and wanted to see the code I wrote. After opening the project, I found that the comments of the previous Java source file were garbled. So I searched Baidu and got the conclusion: the cause of the problem: Because the default encoding in Windows is GBK, Ubuntu is the UTF-8, so in Windows under the annotation, Ubuntu becomes garbled.
There are two solutions:
1. Change the Ubuntu system encoding to GBK, which is the same as the Windows encoding, but I failed to use this method.
Execute Command
Sudo vi/etc/environment
Change the file content:
1. PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
2. LANGUAGE = "zh_CN: zh: en_US: en"
3. # system code UTF-8
4. # LANG = "zh_CN.UTF-8"
5. # change the system default encoding to GBK.
6. GST_ID3_TAG_ENCODING = GBK
7. LANG = zh_CN.GBK
8. LC_CTYLE = zh_CN.GBK
Restart Ubuntu. But I have not succeeded in the experiment. Why? If anyone knows, please leave a message on the blog and let me know.
2. method 2
1) eclipse-> window-> preferences-> General-> Content Types
2) Find the type of the file to be modified. There is a Default encoding below, and enter GBK in the input box.
3) Click Update.
4) Click OK.
5) Restart eclipse
Open the source file and garbled characters disappear.