Ubuntu gedit 中文乱码解决方法

有些在Windows下能够打开的txt文件在Ubuntu下用gedit打开时,中文显示是乱码,这是因为编码方式不同造成的。Windows下默认txt文件的编码方式是GBK,而Ubuntu下的gedit默认没有对GBK的支持。解决方法如下:

在终端运行gconf-editor,(如果没有安装用“sudo apt-get install dconf-tools”安装。

在apps -> gedit-2 -> preference -> encodings里面有个auto-detect,在它的前面加上GBK或GB18030就OK了。

PS:使用的时候,我的preference的目录下面就是没有encodings的选项,因此改用一下方案:

打开终端输入:
gsettings set org.gnome.gedit.preferences.encodings auto-detected "['GB18030', 'GB2312', 'GBK', 'UTF-8', 'BIG5', 'CURRENT', 'UTF-16']"
 
gsettings set org.gnome.gedit.preferences.encodings shown-in-menu "['GB18030', 'GB2312', 'GBK', 'UTF-8', 'BIG5', 'CURRENT', 'UTF-16']"

 此时,重新打开gedit文件,没有中文乱码。


原文地址:https://www.cnblogs.com/duboway/p/3029532.html