On Dec 26, 2003, at 11:07 PM, MenTaLguY wrote:
In any case, we'd still need to store the UTF-8 filename, if only for display in the UI.
Exactly. Since a conversion would be required anyway, it makes sense to keep the canonical Unicode version around.
On some platforms (e.g. Darwin/Mac OS X) where open()/readdir() use a specific, fixed, encoding, which has certain validity rules -- i.e. you _can't_ just give it an arbitrary byte stream (even if such a filename already exists in the filesystem).
To be honest, I really think this isn't our problem to fix. The best we can do is use UTF-8 internally, and call open() and friends with the string converted to LC_CTYPE.
Or glib's g_filename_to_utf8() and g_filename_from_utf8() functions might be appropriate.
g_filename_from_uri() and g_filename_to_uri also look very promising.
Hmmm... speaking of URI's... Looking at some existing solutions might be handy:
http://java.sun.com/j2se/1.4.2/docs/api/java/net/URI.html http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
(the thing to look at in File is how it can be used to work and manipulate paths instead of using bare string manipulation)