pluma encodings
問:如何解決「pluma」開啟檔案,產生中文亂碼的情形?
答:解決方法如下
python 範例
UbuntuMate 16.04
pluma 版本
$ pluma --version
顯示
pluma - Version 1.12.2
探索設定參數
執行
$ gsettings list-recursively | grep pluma | grep encodings
顯示
org.mate.pluma shown-in-menu-encodings ['ISO-8859-15']
org.mate.pluma auto-detected-encodings ['UTF-8', 'CURRENT', 'ISO-8859-15', 'UTF-16']
設定開啟檔案可以辨識的編碼
$ gsettings set org.mate.pluma auto-detected-encodings "['UTF-8', 'BIG5', 'BIG5-HKSCS', 'EUC-TW', 'GB18030', 'GB2312', 'GBK', 'CURRENT', 'ISO-8859-15', 'UTF-16']"
設定選單會顯示的編碼選項
$ gsettings set org.mate.pluma shown-in-menu-encodings "['UTF-8', 'BIG5', 'BIG5-HKSCS', 'EUC-TW', 'GB18030', 'GB2312', 'GBK', 'CURRENT', 'ISO-8859-15', 'UTF-16']"
還原到預設值
執行
gsettings reset org.mate.pluma auto-detected-encodings
gsettings reset org.mate.pluma shown-in-menu-encodings
可以再次執行,觀看結果
$ gsettings list-recursively | grep pluma | grep encodings
探索Schema檔
執行
$ grep auto-detected-encodings /usr/share/glib-2.0/schemas/* -R
顯示
Binary file /usr/share/glib-2.0/schemas/gschemas.compiled matches
/usr/share/glib-2.0/schemas/org.mate.pluma.gschema.xml: <key name="auto-detected-encodings" type="as">
執行
$ grep shown-in-menu-encodings /usr/share/glib-2.0/schemas/* -R
顯示
Binary file /usr/share/glib-2.0/schemas/gschemas.compiled matches
/usr/share/glib-2.0/schemas/org.mate.pluma.gschema.xml: <key name="shown-in-menu-encodings" type="as">
執行
$ dpkg -S /usr/share/glib-2.0/schemas/org.mate.pluma.gschema.xml
顯示
pluma-common: /usr/share/glib-2.0/schemas/org.mate.pluma.gschema.xml
也就是「/usr/share/glib-2.0/schemas/org.mate.pluma.gschema.xml」這個檔,是屬於「pluma-common」這個套件
執行
$ dpkg -L pluma-common | grep schema
顯示
/usr/share/glib-2.0/schemas
/usr/share/glib-2.0/schemas/org.mate.pluma.gschema.xml
/usr/share/glib-2.0/schemas/org.mate.pluma.plugins.time.gschema.xml
/usr/share/glib-2.0/schemas/org.mate.pluma.plugins.filebrowser.gschema.xml