views:

261

answers:

2

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?

+2  A: 

An approximate answer is at: http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx

Basically, the recommendation is to uppercase both strings (using CharUpper, CharUpperBuf, 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.

Doug
+2  A: 

Comparing file names in native code and Don't compare filenames are a couple of good blog posts on this topic. The first has C/C++ code for OrdinalIgnoreCaseCompareStrings, and the second tells you how that doesn't always work for filenames and what to do to mitigate that.

Steve Steiner