之前在Windows下面的代码移到Ubuntu系统后出现中文乱码,因为默认不支持Windows下面的GBK字符集,需要自己加入到配置文件中。
1. 在 /var/lib/locales/supported.d/local文件后面添加:
zh_CN.GBK GBK
zh_CN.GB2312 GB2312
2. 重新配置locals包:
[email protected]:~$ sudo dpkg-reconfigure --force locales
Generating locales...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
en_CA.UTF-8... done
en_DK.UTF-8... done
en_GB.UTF-8... done
en_HK.UTF-8... done
en_IE.UTF-8... done
en_IN.UTF-8... done
en_NG.UTF-8... done
en_NZ.UTF-8... done
en_PH.UTF-8... done
en_SG.UTF-8... done
en_US.UTF-8... done
en_ZA.UTF-8... done
en_ZM.UTF-8... done
en_ZW.UTF-8... done
zh_CN.GB2312... done
zh_CN.GBK... done
zh_CN.UTF-8... up-to-date
zh_SG.UTF-8... up-to-date
Generation complete.
3.配置Eclipse : Windows-> Preferences - > Workspace-> Text file encoding设置 Other = GBK。