如何根据文件系统知道文件名的字符编码 [英] How to know character encoding of file names depending on the filesystem

查看:207
本文介绍了如何根据文件系统知道文件名的字符编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道文件系统中文件名的字符编码,以便在GUI中正确显示它们.

我应该怎么做?

我想我会根据文件系统(FAT,NTFS,ext3等)获得不同的字符编码

谢谢

(我使用C ++,但该主题与语言无关)

解决方案

NTFS是Unicode(UTF-16). exFAT也是Unicode.

原始FAT和fAT32使用OEM字符集(有关更多信息,请参见此问题中查看更多.

上面的unix方法用于大多数文件系统(主要是因为字符集"概念在OS级别比在存储级别具有更多含义).您可以在此处(表2第3列)中查看FS功能和要求. >

I would like to know the character encoding of the file names in a filesystem in order to display correctly them in a GUI.

How should I do this ?

I suppose I get different character encoding depending on the file system (FAT, NTFS, ext3, etc.)

Thank you

(I work in C++ but this topic is not language related)

解决方案

NTFS is Unicode (UTF-16). exFAT is Unicode as well.

Original FAT and fAT32 use OEM character set (read more on MSDN).

On Linux and Unix filename may contain any bytes except NUL and the charater set is not defined. Consequently each application decides itself which one to use. Many applications use UTF8. See more in this question.

The above unix approach is used on most filesystems (mainly because the "charset" concept has more meaning on the OS level than on the storage level). You can check FS capabilities and requirements regarding filename characters here (table 2 column 3).

这篇关于如何根据文件系统知道文件名的字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆