解決 Ubuntu 下 gedit編輯器打開文件出現中文亂碼問題

解決 Ubuntu 中 gedit編輯器打開文件出現中文亂碼問題



1. 問題分析

  1. 在 windows 系統下,.txt 文件默認編碼方式爲 gb18030 格式的中文編碼,而 gedit 默認的編碼方式爲 UTF-8java

  2. 在缺省配置下,用 Ubuntu 的文本編輯器(gedit)打開GB18030(繁體中文用戶請將這裏的出現的GB18030替換成BIG5或BIG5-HKSCS)類型的中文編碼文本文件時,將會出現亂碼。(中文簡體和繁體都顯示亂碼時,則將GB18030,BIG5,BIG5-HKSCS都加上)

    ubuntu

2. 解決方案

1. 查看gedit的版本: gedit --version



2.具體方案

gedit 3.x 版本解決方案

  1. 命令方式
    打開終端,在終端中輸入下列命令便可
// 中文亂碼(‘GB18030‘,‘GB2312‘,‘GBK‘中文簡體字符集,‘BIG5‘,’BIG5-HKSCS' 中文繁體字符集)
  gsettings set org.gnome.gedit.preferences.encodings candidate-encodings "['GB18030', 'UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']"

  1. 圖形方案

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’]




編碼

gedit 2.x 版本解決方案

  1. 命令方式
    打開終端,在終端中輸入下列命令
// 中文亂碼(‘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]"

  1. 圖形方案

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

相關文章
相關標籤/搜索