www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - unicode filenames: std.stream.File and std.path.listdir

reply "Carlos Santander B." <carlos8294 msn.com> writes:
Take this:

import std.stream;
void main ()
{
    auto File f = new File("año",FileMode.In);
    stdout.writeLine( f.readLine() );
}

If saved as 8-bit or UCS-2 (whatever that is), it doesn't work. In fact, it
creates a new file named "año". But when saved as UTF-8 it works as
expected.

The really bad part is that if instead I iterate over all the files
(listdir(curdir)), it doesn't matter how I save it, it doesn't work anyway.
Which means, the output from listdir can't be safely used with
std.stream.File.

In conclusion, I believe that listdir should also return dchar [][] and
wchar [][], and std.stream.File should accept wchar [] and dchar [] for
filenames.

-----------------------
Carlos Santander Bernal
Jun 06 2004
parent reply "Walter" <newshound digitalmars.com> writes:
The bug is that std.stream needs to do the unicode conversions on the
filenames like the std.file functions do.

BTW, thanks for thrashing this stuff for us.
Jun 08 2004
next sibling parent "Carlos Santander B." <carlos8294 msn.com> writes:
"Walter" <newshound digitalmars.com> escribió en el mensaje
news:ca3t1k$9ga$1 digitaldaemon.com
| BTW, thanks for thrashing this stuff for us.

No problem, I just try to help in any way I can.

-----------------------
Carlos Santander Bernal
Jun 08 2004
prev sibling parent "Carlos Santander B." <carlos8294 msn.com> writes:
"Walter" <newshound digitalmars.com> escribió en el mensaje
news:ca3t1k$9ga$1 digitaldaemon.com
| The bug is that std.stream needs to do the unicode conversions on the
| filenames like the std.file functions do.
|
| BTW, thanks for thrashing this stuff for us.

Ok, this was easy. Attached is the fixed std.stream.
Note the lines 1330-1336: those could be removed if std.file.useWfuncs was
declared as package.

-----------------------
Carlos Santander Bernal
Jun 08 2004