LinuxSir.cn,穿越时空的Linuxsir!

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

关于 GBK 文件名

[复制链接]
发表于 2006-4-17 13:55:50 | 显示全部楼层 |阅读模式
我的 NTFS 分区中有许多文件名中包含 GBK 字符(非 GB2312 字符)的文件,比如日文。

可是我看了 Linux 内核配置 File Systems\Native Language Support 中并没有支持 GBK 编码,只有 GB2312(CP936),也就是说 mount 的 -o iocharset 中不能指定 GBK。这是不是表明 Linux 不能处理那些包含非 GB2312 的 GBK 字符的文件名呢?

我目前的设置是
LANG=zh_CN.GBK
LC=MESSAGES=en_US
分区使用 iocharset=gb2312 挂上

这样的话,在 KDE 的 Konsole 窗口中用 ls 查看,可以看到 NTFS 中的 GBK 文件名,但是却不能用 cd 进入。在 Konqueror 图形窗口中直接无法看见那些包含非 GB2312 的 GBK 字符的文件名。

有没有人有什么好办法处理 GBK 文件名呢?
:ask
多谢!
发表于 2006-4-17 14:14:35 | 显示全部楼层
ntfs是以unicode存储文件名的,所以只有以nls=utf8挂载ntfs分区,才能保证一对一的对unicode文件名的转换。如果是以nls=gb2312挂载,无法文件名包含有不可转换的字符时,就将其隐藏了。而vfat虽然也是以unicode存储长文件名,但以iocharset=gb2312挂载时遇到无法转换的unicode字符会以转义序列显示。
回复 支持 反对

使用道具 举报

发表于 2006-4-17 14:15:05 | 显示全部楼层
ntfs是以unicode存储文件名的,所以只有以nls=utf8挂载ntfs分区,才能保证一对一的对unicode文件名的转换。如果是以nls=gb2312挂载,无法文件名包含有不可转换的字符时,就将其隐藏了。而vfat虽然也是以unicode存储长文件名,但以iocharset=gb2312挂载时遇到无法转换的unicode字符会以转义序列显示。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-4-17 15:14:57 | 显示全部楼层
多谢!

问题已经解决,果然如楼上所说

虽然我的 mount 不知如何不支持 -o nls=utf8 但可以使用 -o utf8 代替
回复 支持 反对

使用道具 举报

发表于 2006-4-17 15:23:45 | 显示全部楼层
可能老版本只支持的iocharset吧
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-4-17 15:24:32 | 显示全部楼层
刚才看了一下,发现还有少量字符显示为方框,不知这是不是由于字体中没有该字符
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-4-17 15:26:53 | 显示全部楼层
Post by seamonkey
可能老版本只支持的iocharset吧


可是我的 man mount 里却有关于 nls 的说明,奇怪哦
回复 支持 反对

使用道具 举报

发表于 2006-4-17 15:39:15 | 显示全部楼层
第一个应该是字体的问题。

第二个不知道,内核文档中是这么说的:


  1. iocharset=name                Deprecated option.  Still supported but please use
  2.                         nls=name in the future.  See description for nls=name.

  3. nls=name                Character set to use when returning file names.
  4.                         Unlike VFAT, NTFS suppresses names that contain
  5.                         unconvertible characters.  Note that most character
  6.                         sets contain insufficient characters to represent all
  7.                         possible Unicode characters that can exist on NTFS.
  8.                         To be sure you are not missing any files, you are
  9.                         advised to use nls=utf8 which is capable of
  10.                         representing all Unicode characters.

  11. utf8=<bool>                Option no longer supported.  Currently mapped to
  12.                         nls=utf8 but please use nls=utf8 in the future and
  13.                         make sure utf8 is compiled either as module or into
  14.                         the kernel.  See description for nls=name.
复制代码
回复 支持 反对

使用道具 举报

发表于 2006-4-17 15:39:46 | 显示全部楼层
第一个应该是字体的问题。

第二个不知道,内核文档中是这么说的:


  1. iocharset=name                Deprecated option.  Still supported but please use
  2.                         nls=name in the future.  See description for nls=name.

  3. nls=name                Character set to use when returning file names.
  4.                         Unlike VFAT, NTFS suppresses names that contain
  5.                         unconvertible characters.  Note that most character
  6.                         sets contain insufficient characters to represent all
  7.                         possible Unicode characters that can exist on NTFS.
  8.                         To be sure you are not missing any files, you are
  9.                         advised to use nls=utf8 which is capable of
  10.                         representing all Unicode characters.

  11. utf8=<bool>                Option no longer supported.  Currently mapped to
  12.                         nls=utf8 but please use nls=utf8 in the future and
  13.                         make sure utf8 is compiled either as module or into
  14.                         the kernel.  See description for nls=name.
复制代码
回复 支持 反对

使用道具 举报

发表于 2006-4-17 16:22:58 | 显示全部楼层
LINUX核心本身是不区分GBK和GB2312的,它都叫GB2312或cp936(外国人可能不了解中国国情)这一点你看下nls/cp936.c里的码表就知道了,底位是有小天A0的值的
据它说这个码表是来自微软的,可码表与GBK码表有一些不同,后来我用GBK的码表改了一个还行,后来我就一直用我自己的码表
另外那个cp936的函数也有问题,在GB18030编码中明确表示中文是变长码,可它本身并不支持,只支持双字节,其它我们的GBK也是变长的即单字节的和双字节的,没办法,如果真想用就自己改一下吧。
回复 支持 反对

使用道具 举报

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

本版积分规则

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