Problem with Cyrillic file names on FAT

Sep 27, 2011 at 12:57 PM

I've found an issue with file name and contains Cyrillic characters (probably same issue is true for other non-Latin encoding but I didn't check).

I have small VMWare image with 2 directories: one named in English and one in Russian (specifically crafted test image). VMWare  image file is perfectly valid. Russian directory name is also valid. Image can be opened successfully in VMWare Player and WinImage utilities.

When I try to open this image and get all directories library throws exception that '?' is not a valid character for file name. I've found that source of the problem is FatUtilities.NormalizeFileName function. In particular it's first line :

string roundTripped = Encoding.Default.GetString(Encoding.Default.GetBytes(name));

Variable 'name' here is a result of BytesToString function and call to Encoding.Default.GetBytes(name) transform all Cyrillic characters to '?' symbols. Subsequent check for invalid characters in file name yields an exception mentioned above.

Exception  can be resolved with replacing GetBytes/GetString pair with StringToBytes/GetString/GetBytes/BytesToString but I'm nor sure is this is valid solution. This change removes exception and image can be opened but directory name returned from this FS entry still in form on BytesToString result and it is a bit unclear how to use this value in application.

Coordinator
Oct 8, 2011 at 10:10 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 8, 2011 at 10:08 AM

Hi.

I can't change issue status and reopen it so I've decided to write here. Issue kinda left incomplete. You probably missed my last comment in the issue. There is still a problem with deleted entries that doesn't recognized as such because of encoding conversion. And sometime it leads to exception about directory item not found during directory listing.

Coordinator
Dec 10, 2011 at 10:40 AM

Sorry, I had missed that - I've re-opened.

Cheers,

Ken