Any portable way get a filename in UTF-8 or to get the FS encoding ?



Hello,

I am trying to devise a simple tool in which I read many directory and file names (to compare two directories).

I never wrote code that I would port to different systems, but I would not mind doing it now.

So I download and read sus v2 and sus v3 to see the openddir/readdir/closedir functions, but they only return char[] strings for file names and they say nothing about the encoding of the file names.

A computer system may mount and/or access many kinds of file systems. NTFS as I know is an UNICODE file system (Sorry I do not know how ufs or extfs are). When mounting FAT systems one can explicitly specify a charset for all the file names.

I have seen _wreaddir function in some implementations, but is there a portable way to get a file's name in UTF-8 or to get a file name in the underlaying encoding of its file system and to get the encoding ?

Are POSIX implementations required to convert the file name return by readdir to the application's execution character set ?

Thank you,
Timothy Madden,
Romania
.



Relevant Pages

  • Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
    ... portable way to get a file's name in UTF-8 or to get a file name in the ... underlaying encoding of its file system and to get the encoding? ... The encoding used for file names on any given file system is never ... wants those file names to be interpreted as (eg. the LC_* environment ...
    (comp.unix.programmer)
  • Re: Ada.Directories problems, a summary
    ... Name encoding. ... Either String versions should be UTF-8 or else replaced ... string names to file system names? ... example, to find drive letters under Windows, network shares, mount points ...
    (comp.lang.ada)
  • Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
    ... So I download and read sus v2 and sus v3 to see the openddir/readdir/closedir functions, but they only return charstrings for file names and they say nothing about the encoding of the file names. ... I have seen _wreaddir function in some implementations, but is there a portable way to get a file's name in UTF-8 or to get a file name in the underlaying encoding of its file system and to get the encoding? ... A filename is just a NUL terminated string which is completely compatible with UTF-8. ...
    (comp.unix.programmer)
  • Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
    ... I would like a standard way to get that encoding, and the file system should be the first to know about it. ... Even more, if the user has two apps, one that only knows SHIFT_JIS and one that only knows ANSI, the user just needs to arrange that current locale for the first app is SHIFT_JIS, and the current locale for the second app is ANSI. ...
    (comp.unix.programmer)
  • Re: A Great Idea (tm) about reimplementing NLS.
    ... > I don't think that any filesystem knows about the encoding of every ... > IOW given a FAT filesystem on an USB stick, ... > conversion layer in the kernel). ... file system implementation to decide to use it or not. ...
    (Linux-Kernel)