zoukankan      html  css  js  c++  java
  • 解决 Ubuntu 下 gedit编辑器打开文件出现中文乱码问题

    解决 Ubuntu 中 gedit编辑器打开文件出现中文乱码问题



    1. 问题分析

    1. 在 windows 系统下,.txt 文件默认编码方式为 gb18030 格式的中文编码,而 gedit 默认的编码方式为 UTF-8

    2. 在缺省配置下,用 Ubuntu 的文本编辑器(gedit)打开GB18030(繁体中文用户请将这里的出现的GB18030替换成BIG5或BIG5-HKSCS)类型的中文编码文本文件时,将会出现乱码。(中文简体和繁体都显示乱码时,则将GB18030,BIG5,BIG5-HKSCS都加上)

    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-editor

          sudo apt install dconf-editor      // 在终端中输入,安装 dconf-editor
    

    step 2: 运行 dconf-editor
    在终端中输入dconf-editor,打开econf-editor

    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-editor

          sudo apt install dconf-editor      // 在终端中输入,安装 dconf-editor
    

    step 2: 运行 dconf-editor
    在终端中输入dconf-editor,打开econf-editor

    step 3: 展开 /apps/gedit-2/preferences/encodings

    step 4: 在auto_detected键中新增GB18030,并使它位于UTF-8前面,确定。



  • 相关阅读:
    mac下编写命令脚本
    mac环境mongodb安装小坑
    JS
    设计模式:装饰器
    proxy 数据帧听
    react hook 简单实现
    报错:java.lang.NumberFormatException: null
    git回滚到指定版本
    1109. 航班预订统计 力扣(中等) 差分数组 不会但神奇
    528. 按权重随机选择 力扣(中等) 前缀和rand()
  • 原文地址:https://www.cnblogs.com/cure/p/14170696.html
Copyright © 2011-2022 走看看