UBuntu中增加中文字符编码的方法

来源:互联网 发布:武汉家装网源码 编辑:程序博客网 时间:2024/06/08 02:15
在Widnows XP下的FTP服务器中有中文文件名 ,今天使用ftp命令,发现不能显示中文文件名,只能显示????。于是到网上查了一些资料,也没有找到好的解决方法,只是有人说使用图形化的ftp工具gftp,安装方法:sudo apt-get install gftp,另外还要增加中文字符编码zh_CN.GBK即可即可。在这里总结一下Ubuntu下增加中文字符编码的方法。
一. Ubuntu默认的中文字符编码
Ubuntu默认的中文字符编码为zh_CN.UTF-8,这个可以在/etc/environment中看到:
sudo gedit
/etc/environment
可以看到如下内容:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en" 第二行即是默认的中文字符编码。注:可以通过这里修改默认的中文编码字符,比如修改为:zh_CN.GBK。

二. 添加中文字符编码的方法
1. 直接使用locale-gen
在超级终端输入命令:
sudo locale-gen zh_CN.GB18030
即可完成中文字符集的添加。完成后可以转到
/usr/lib/locale/,下面已经有一个zh_CN.gb18030文件夹;在超级终端输入命令:gedit /var/lib/locales/supported.d/local,可以发现文件中多了一行:zh_CN.GB18030 GB18030。说明添加成功。

2. 通过修改/var/lib/locales/supported.d/local文件
在终端输入命令行
sudo gedit /var/lib/locales/supported.d/local
可以看到如下内容:

zh_CN.UTF-8 UTF-8
en_US.UTF-8 UTF-8
在文件尾添加中文字符集
zh_CN.GBK GBK
保存后退出。在超级终端输入命令:
sudo dpkg-reconfigure locales

Generating locales...
  en_AU.UTF-8... done
  en_BW.UTF-8... done
  en_CA.UTF-8... done
  en_DK.UTF-8... done
  en_GB.UTF-8... done
  en_HK.UTF-8... done
  en_IE.UTF-8... done
  en_IN.UTF-8... done
  en_NZ.UTF-8... done
  en_PH.UTF-8... done
  en_SG.UTF-8... done
  en_US.UTF-8... done
  en_ZA.UTF-8... done
  en_ZW.UTF-8... done
  zh_CN.GBK... done
  zh_CN.UTF-8... up-to-date
  zh_HK.UTF-8... done
  zh_SG.UTF-8... done
  zh_TW.UTF-8... done
Generation complete.

即可生成相应文件:/usr/lib/locale/zh_CN.gbk/
注:也可使用locale-gen