Encoding of file names

"Martin v. Löwis" martin at v.loewis.de
Sat Dec 10 05:00:45 EST 2005


Tom Anderson wrote:
>> This is a fact, but it is not a key thing. Of course Windows is 
>> applying a non-roundtrippable character encoding. What else could it do?
> 
> 
> Well, i'm no great thinker, but i'd say that errors should never pass 
> silently, and that in the face of ambiguity, one should refuse the 
> temptation to guess. So, as i said in my post, if the name couldn't be 
> translated losslessly, an error should be raised.

I believe this would not work, the way the API is structured. You do
first FindFirstFile, getting a file name and a ahandle. Then you do
FindNextFile repeatedly, passing the handle. An error of FindFirstFile
is indicated by returning an invalid handle.

So if you wanted FindFirstFile to return an error for unencodable file
names, it would not be possible to get a listing of the other files
in the directory.

FindFirstFile also gives the 8.3 file name (if present), and that is
valid without problems.

Regards,
Martin



More information about the Python-list mailing list