1. 程式人生 > >解決FAT32檔案系統分割槽中文檔名在Linux下顯示亂碼

解決FAT32檔案系統分割槽中文檔名在Linux下顯示亂碼

原貼:

http://ericzqma.blogs.mu/2009/06/11/%E8%A7%A3%E5%86%B3fat32%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F%E5%88%86%E5%8C%BA%E4%B8%AD%E6%96%87%E6%96%87%E4%BB%B6%E5%90%8D%E5%9C%A8linux%E4%B8%8B%E6%98%BE%E7%A4%BA%E4%B9%B1%E7%A0%81/

升級到Fedora 11後,使用以前的fstab自動掛載我的fat32分割槽居然發現我的fat32檔案系統中的中文檔名顯示為亂碼。

找了下相關資料發現是iocharset的問題:

iocharset=name — Character set to use for converting between the encoding is used for user visible filename and 16 bit Unicode characters. Long filenames are stored on disk in Unicode format, but Unix for the most part doesn’t know how to deal with Unicode. By default, FAT_DEFAULT_IOCHARSET setting is used.

Windows檔案系統的長檔名是用16位的Unicode儲存的, 而Linux檔案系統不支援16位的字元,所以需要在兩者之間轉換,這就是iocharset要完成的功能。

使用utf8=1選項進行mount就可以了,相應的fstab行如下:

/dev/sda1    /mnt/wxp    vfat    umask=0000,utf8=1   0 0

使用mount命令時加入 -o utf8=1就可以了。

不建議使用iocharset=utf8選項:
NOTE: “iocharset=utf8″ is not recommended.
If unsure, you should consider the following option instead.
utf8=<bool>   — UTF-8 is the filesystem safe version of Unicode that is used by the console.
It can be be enabled for the filesystem with this option.
If ‘uni_xlate’ gets set, UTF-8 gets disabled.
<bool> : 0,1,yes,no,true,false

Reference:
http://linuxman.blog.ccidnet.com/blog-htm-do-showone-type-blog-itemid-283304-uid-60710.html