Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
- From: roubert@xxxxxxxxx (Fredrik Roubert)
- Date: Mon, 8 Oct 2007 09:14:12 +0000 (UTC)
On Sun, 07 Oct 2007 22:22:12 +0300, Timothy Madden wrote:
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 ?
The encoding used for file names on any given file system is never
specified in a POSIX system, and a user is free to create file names
using several different encodings even on the same file system. (I
actually have such a file system myself, where most file names are
encoded in UTF-8 but the file names in one directory are encoded in
ISO-8859-1.)
A process that wants to interpret the bytes that makes up a file name
must look at its environment for hints about which encoding the user
wants those file names to be interpreted as (eg. the LC_* environment
variables). You can use the mbstowcs() library function to automatically
convert a string into a wide character string according to the encoding
specified by the current environment.
Cheers // Fredrik Roubert
--
Dyre Halses gate 10 | +47 73568556 / +47 41266295
NO-7042 Trondheim | http://www.df.lth.se/~roubert/
.
- Follow-Ups:
- Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
- From: Timothy Madden
- Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
- References:
- Any portable way get a filename in UTF-8 or to get the FS encoding ?
- From: Timothy Madden
- Any portable way get a filename in UTF-8 or to get the FS encoding ?
- Prev by Date: Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
- Next by Date: Need suggestion on UDP Concurrent server
- Previous by thread: Any portable way get a filename in UTF-8 or to get the FS encoding ?
- Next by thread: Re: Any portable way get a filename in UTF-8 or to get the FS encoding ?
- Index(es):
Relevant Pages
|