在 windows 系統下,.txt 文件默認編碼方式爲 gb18030 格式的中文編碼,而 gedit 默認的編碼方式爲 UTF-8java
在缺省配置下,用 Ubuntu 的文本編輯器(gedit)打開GB18030(繁體中文用戶請將這裏的出現的GB18030替換成BIG5或BIG5-HKSCS)類型的中文編碼文本文件時,將會出現亂碼。(中文簡體和繁體都顯示亂碼時,則將GB18030,BIG5,BIG5-HKSCS都加上)
ubuntu
gedit --version
// 中文亂碼(‘GB18030‘,‘GB2312‘,‘GBK‘中文簡體字符集,‘BIG5‘,’BIG5-HKSCS' 中文繁體字符集) gsettings set org.gnome.gedit.preferences.encodings candidate-encodings "['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']"
step 1: 安裝 dconf-editorwindows
sudo apt install dconf-editor // 在終端中輸入,安裝 dconf-editor
step 2: 運行 dconf-editor
在終端中輸入dconf-editor
,打開econf-editorapp
step 3: 展開 org/gnome/gedit/preferences/encodings編輯器
step 4: 把 "candidate-encodings" 的值更改成 [‘GB18030’, ‘UTF-8’, ‘CURRENT’, ‘ISO-8859-15’, ‘UTF-16’]
編碼
// 中文亂碼(‘GB18030‘,‘GB2312‘,‘GBK‘中文簡體字符集,‘BIG5‘,’BIG5-HKSCS' 中文繁體字符集) gconftool-2 --set --type=list --list-type=string /apps/gedit-2/preferences/encodings/auto_detected "[GB18030,UTF-8,CURRENT,ISO-8859-15,UTF-16]"
step 1: 安裝 dconf-editorcode
sudo apt install dconf-editor // 在終端中輸入,安裝 dconf-editor
step 2: 運行 dconf-editor
在終端中輸入dconf-editor
,打開econf-editorblog
step 3: 展開 /apps/gedit-2/preferences/encodingsstring
step 4: 在auto_detected鍵中新增GB18030,並使它位於UTF-8前面,肯定。it