默认情况下,Ubuntu 11.10中使用Gedit打开GB编码的文件时,会有中文乱码的问题。其实在之前的Ubuntu版本(10.10以及之前的版本)中,是有方法解决的。但自从11.04版本后,换了图形界面,其配置方式也发生了变化,改为使用gsettings。可惜的是,默认只提供命令行的方式,无形中增加了配置的难度。令人感叹,新的Unity界面不如传统的Gnome好用。
其步骤如下:
1.查看默认配置。
输入:
gsettings get org.gnome.gedit.preferences.encodings auto-detected
结果:
['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']
2.设置新值,添加GB18030一项。
输入:
gsettings set org.gnome.gedit.preferences.encodings auto-detected "['UTF-8', 'GB18030', 'CURRENT', 'ISO-8859-15', 'UTF-16']"
3.再次查看设置后的配置。
输入:
gsettings get org.gnome.gedit.preferences.encodings auto-detected
结果:
['UTF-8', 'GB18030', 'CURRENT', 'ISO-8859-15', 'UTF-16']
4.重新打开产生乱码的文件,就会看到可以正常显示中文了。
其步骤如下:
1.查看默认配置。
输入:
gsettings get org.gnome.gedit.preferences.encodings auto-detected
结果:
['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']
2.设置新值,添加GB18030一项。
输入:
gsettings set org.gnome.gedit.preferences.encodings auto-detected "['UTF-8', 'GB18030', 'CURRENT', 'ISO-8859-15', 'UTF-16']"
3.再次查看设置后的配置。
输入:
gsettings get org.gnome.gedit.preferences.encodings auto-detected
结果:
['UTF-8', 'GB18030', 'CURRENT', 'ISO-8859-15', 'UTF-16']
4.重新打开产生乱码的文件,就会看到可以正常显示中文了。