Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 File Name Comparison

Does anyone know what culture settings Win32 uses when dealing with case-insensitive files names?

Is this something that varies based on the user's culture, or are the casing rules that Win32 uses culture invariant?

like image 982
Scott Wisniewski Avatar asked Jan 04 '09 05:01

Scott Wisniewski


People also ask

What symbols can be used in file names?

Supported characters for a file name are letters, numbers, spaces, and ( ) _ - , . *Please note file names should be limited to 100 characters. Characters that are NOT supported include, but are not limited to: @ $ % & \ / : * ? " ' < > | ~ ` # ^ + = { } [ ] ; !

Which special character should be avoided during naming a file?

Don't use the period character consecutively in the middle of a file name. Don't start or end your filename with a space, period, hyphen, or underline.


1 Answers

An approximate answer is at Comparing Unicode file names the right way.

Basically, the recommendation is to uppercase both strings (using CharUpper, CharUpperBuff, or LCMapString), then compare using a binary comparison (i.e. memcmp or wmemcmp, not CompareString with an invariant locale). The file system doesn't do Unicode normalization, and the case rules are not dependent on locale settings.

There are unfortunate ambiguous cases when dealing with characters whose casing rules have changed across different versions of Unicode, but it's about as good as you can do.

like image 148
Doug Avatar answered Nov 01 '22 19:11

Doug