There is the POSIX access()
, but I'm looking for a wide character version.
views:
83answers:
1
+1
A:
There is no such thing as a "wide-character filename" on Linux. Get the system charset via nl_langinfo()
and encode to that charset before calling access()
.
Ignacio Vazquez-Abrams
2010-01-03 02:55:05
Don't forget to `setlocale(LC_ALL, "")` first -- all C programs start in the C locale, you must switch to the environment-specified locale manually.
ephemient
2010-01-03 18:43:32
Thanks. In a way this is a pity, 'cos it looks like you can't mix languages when naming files. Can you?
Srikumar
2010-01-04 11:03:18
UNIX **filenames** are just a array of bytes, language/encoding is not specified; it's up to each individual application to interpret those bytes however they wish. (Yes, this does seem archaic. That's because it is.) So yes, you could use different encodings for different filenames, but someone else traversing the filesystem would not understand. These days, though, all modern Linux distros use UTF-8 by default -- same encoding regardless of language.
ephemient
2010-01-04 15:08:34
Thanks. I don't run linux all that often and this is good to know ... and with a sigh of relief actually.
Srikumar
2010-01-05 05:52:17