LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 932|回复: 5

问个基础问题,locale ...

[复制链接]
发表于 2007-5-28 11:25:15 | 显示全部楼层 |阅读模式
zh_CN.UTF-8和zh_CN.UTF8有区别吗?
今天发现控制台的locale(zh_CN.UTF8)和xterm(zh_CN.UTF-8)中的不一样,似乎是某次emerge world后的结果。。。
发表于 2007-5-28 12:44:56 | 显示全部楼层
Post by schoolwind

今天发现控制台的locale(zh_CN.UTF8)和xterm(zh_CN.UTF-8)中的不一样
不明白,什么意思?
你把你执行过的命令和结果都贴出来
回复 支持 反对

使用道具 举报

发表于 2007-5-28 13:33:31 | 显示全部楼层
可能你其中一个写错了吧
zh_CN.UTF-8 should be correct
回复 支持 反对

使用道具 举报

发表于 2007-5-28 13:37:13 | 显示全部楼层
关键看你的/etc/locale.gen里怎么定义。zh_CN.UTF-8是通常的名称,其实你把它定义成zh_CN.UTF--8也是可以的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-5-28 13:55:14 | 显示全部楼层
Post by zhllg
不明白,什么意思?
你把你执行过的命令和结果都贴出来
关键看你的/etc/locale.gen里怎么定义。zh_CN.UTF-8是通常的名称,其实你把它定义成zh_CN.UTF--8也是可以的。
zzl0@Gentoo ~ $ cat /etc/locale.gen
# /etc/locale.gen: list all of the locales you want to have on your system
#
# The format of each line:
# <locale> <charmap>
#
# Where <locale> is a locale located in /usr/share/i18n/locales/ and
# where <charmap> is a charmap located in /usr/share/i18n/charmaps/.
#
# All blank lines and lines starting with # are ignored.
#
# For the default list of supported combinations, see the file:
# /usr/share/i18n/SUPPORTED
#
# Whenever glibc is emerged, the locales listed here will be automatically
# rebuilt for you.  After updating this file, you can simply run `locale-gen`
# yourself instead of re-emerging glibc.

en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN.GB18030 GB18030
zh_CN.GBK     GBK
zh_CN.GB2312  GB2312
zh_CN.UTF-8   UTF-8
zzl0@Gentoo ~ $ locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=

控制台:locale > locale.txt
zzl0@Gentoo ~ $ cat locale.txt
LANG=zh_CN.UTF8
LC_CTYPE="zh_CN.UTF8"
LC_NUMERIC="zh_CN.UTF8"
LC_TIME="zh_CN.UTF8"
LC_COLLATE="zh_CN.UTF8"
LC_MONETARY="zh_CN.UTF8"
LC_MESSAGES="zh_CN.UTF8"
LC_PAPER="zh_CN.UTF8"
LC_NAME="zh_CN.UTF8"
LC_ADDRESS="zh_CN.UTF8"
LC_TELEPHONE="zh_CN.UTF8"
LC_MEASUREMENT="zh_CN.UTF8"
LC_IDENTIFICATION="zh_CN.UTF8"
LC_ALL=
zzl0@Gentoo ~ $ cat /etc/env.d/100i18n
LANGUAGE=zh_CN
zzl0@Gentoo ~ $ cat /etc/env.d/99locale
LANG=zh_CN.UTF-8
CCACHE_DIR="/var/tmp/ccache"

问题似乎不大。我觉得是不是bash的问题?还请各位指点一下gentoo都在具体哪几个文件来定义?以前用fc2时,记得是zh_CN.UTF-8:confused:
回复 支持 反对

使用道具 举报

发表于 2007-5-28 14:51:21 | 显示全部楼层
我觉得很奇怪
因为一般来说终端程序不会改变环境变量的设定
其实具体用UTF-8,还是UTF8,utf8都是一样的
在glibc内部,这个字符串会被normalize
http://www.gnu.org/software/libc ... tized-software.html
The only new thing is the normalized codeset entry. This is another goodie which is introduced to help reducing the chaos which derives from the inability of the people to standardize the names of character sets. Instead of ISO-8859-1 one can often see 8859-1, 88591, iso8859-1, or iso_8859-1. The normalized codeset value is generated from the user-provided character set name by applying the following rules:

   1. Remove all characters beside numbers and letters.
   2. Fold letters to lowercase.
   3. If the same only contains digits prepend the string "iso".

So all of the above name will be normalized to iso88591. This allows the program user much more freely choosing the locale name.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表