Chinaunix首页 | 论坛 | 博客
  • 博客访问: 365635
  • 博文数量: 56
  • 博客积分: 2721
  • 博客等级: 中校
  • 技术积分: 460
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-29 16:18
文章分类

全部博文(56)

文章存档

2014年(1)

2011年(15)

2010年(5)

2008年(35)

分类: LINUX

2008-08-22 13:52:02

系统:英文版的Redhat企业版
症状:英文显示没问题;中文输入法也没问题;中文网页显示为乱码,不管是用GB18030还是2312
解决:安装fonts-chinese-3.02-9.6.el5.

此时相关如下:
[root@localhost ~]# rpm -qa | grep fonts- | wc -l
14
[root@localhost ~]# rpm -qa | grep fonts-
bitmap-fonts-0.3-5.1.1
xorg-x11-fonts-misc-7.1-2.1.el5
fonts-chinese-3.02-9.6.el5
xorg-x11-fonts-base-7.1-2.1.el5
xorg-x11-fonts-75dpi-7.1-2.1.el5
urw-fonts-2.3-6.1.1
xorg-x11-fonts-100dpi-7.1-2.1.el5
bitstream-vera-fonts-1.10-7
ghostscript-fonts-5.50-13.1.1
xorg-x11-fonts-ISO8859-1-75dpi-7.1-2.1.el5
xorg-x11-fonts-Type1-7.1-2.1.el5
xorg-x11-fonts-ISO8859-1-100dpi-7.1-2.1.el5
dejavu-lgc-fonts-2.10-1
xorg-x11-fonts-truetype-7.1-2.1.el5
[root@localhost ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
[root@localhost ~]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
[root@localhost ~]#

网上提供的消除中文乱码的方法如下,只是一种治标的方法,应该是先查看有没有相关的字体包已经安装,再考虑更改如下设置:

将i18n内容改为

LANG="zh_CN.GB18030"
LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"
SYSFONT="lat0-sun16"

------------------------------------

下述命令如果有下述信息说明装有中文字体:


[root@localhost ~]# xlsfonts | grep gb
-isas-fangsong ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0
-isas-song ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0
-isas-song ti-medium-r-normal--24-240-72-72-c-240-gb2312.1980-0
-misc-ar pl shanheisun uni-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
-misc-ar pl zenkai uni-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
-misc-zysong18030-medium-r-normal--0-0-0-0-c-0-gb18030.2000-0
-misc-zysong18030-medium-r-normal--0-0-0-0-c-0-gb2312.1980-0
-misc-zysong18030-medium-r-normal--0-0-0-0-c-0-gbk-0
-urw-dingbats-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific
hanzigb16fs
hanzigb16st
hanzigb24st

字体所在目录:/usr/share/locale


[root@localhost ~]# cd /usr/share/locale
[root@localhost locale]#ll

................................................

drwxr-xr-x 4 root root 4096 Dec 14 2006 zh_CN
drwxr-xr-x 3 root root 4096 Sep 26 17:38 zh_CN.GB2312
drwxr-xr-x 3 root root 4096 Sep 26 17:31 zh_HK
drwxr-xr-x 4 root root 4096 Dec 14 2006 zh_TW
drwxr-xr-x 3 root root 4096 Sep 26 17:38 zh_TW.Big5
drwxr-xr-x 3 root root 4096 Sep 26 17:31 znd
drwxr-xr-x 3 root root 4096 Sep 26 17:31 zu
drwxr-xr-x 3 root root 4096 Sep 26 17:31 zun

[root@localhost locale]# cd zh_CN
[root@localhost zh_CN]# ll
total 16
drwxr-xr-x 2 root root 4096 Oct 12 11:35 LC_MESSAGES
drwxr-xr-x 2 root root 4096 Sep 26 17:35 LC_TIME
[root@localhost zh_CN]#

LC_MESSAGES目录中是MO (Machine Object) files,可以理解为中文库文件,示例如下:
[root@localhost zh_CN]# cd LC_MESSAGES/
[root@localhost LC_MESSAGES]# msgunfmt bindconf.mo -o /tmp/ttt.po
[root@localhost LC_MESSAGES]#
[root@localhost LC_MESSAGES]# cat /tmp/ttt.po| more
msgid ""
msgstr ""
"Project-Id-Version: zh_CN\n"
"Report-Msgid-Bugs-T \n"
"POT-Creation-Date: 2007-09-11 09:59+0800\n"
"PO-Revision-Date: 2005-12-07 11:33+1000\n"
"Last-Translator: \n"
"Language-Team: <>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.9.1\n"

msgid ""
"\n"
"\n"
"\n"
"\n"
"\n"
msgstr ""
"\n"
"\n"
"\n"
"\n"
"\n"

msgid ""
"\n"
" Note that enabling the update forwarding feature on a slave server may "
"expose master servers relying on insecure IP address based access control to "
"attacks."
msgstr ""
"\n"
"请注意,在一个从服务器上启用更新转发功能可能会使那些依赖基于访问控制的不安全"
"的 IP 地址的主服务器受到恶意攻击。"
----more----
定义区域语言的配置文件位置:

[root@localhost ~]# cd /usr/share/i18n/
[root@localhost i18n]# ll
total 32
drwxr-xr-x 2 root root 12288 Sep 26 17:31 charmaps
drwxr-xr-x 2 root root 12288 Sep 26 17:31 locales
[root@localhost i18n]# ll charmaps/GB*
-rw-r--r-- 1 root root 472428 Jan 15 2007 charmaps/GB18030.gz
-rw-r--r-- 1 root root 1603 Jan 15 2007 charmaps/GB_1988-80.gz
-rw-r--r-- 1 root root 44803 Jan 15 2007 charmaps/GB2312.gz
-rw-r--r-- 1 root root 119113 Jan 15 2007 charmaps/GBK.gz

[root@localhost i18n]# ll locales/zh_*
-rw-r--r-- 1 root root 5618 Jan 15 2007 locales/zh_CN
-rw-r--r-- 1 root root 5851 Jan 15 2007 locales/zh_HK
-rw-r--r-- 1 root root 6102 Jan 15 2007 locales/zh_SG
-rw-r--r-- 1 root root 5605 Jan 15 2007 locales/zh_TW
以前还有/usr/share/i18n/repertoiremaps目录和其中相关的配置文件,现在已经不用。

[root@localhost i18n]# man localedef 用来生成区域设置

修改系统编码变换设置,告诉系统如何将汉字编码转换为系统内部码:

[root@localhost ~]# locate gconv-modules //查找配置文件位置
/usr/lib/gconv/gconv-modules
/usr/lib/gconv/gconv-modules.cache


XFree86设置:

[root@localhost ~]# locate locale.dir
/usr/share/X11/locale/locale.dir

环境变量的设置:

[root@localhost ~]# echo $LANG //这是我电脑上的配置
en_US.UTF-8
阅读(1087) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~