This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, paul.moore, sogom, steve.dower, tim.golden, zach.ware
Date 2020-12-29.15:48:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1609256921.73.0.993353075096.issue42658@roundup.psfhosted.org>
In-reply-to
Content
> "lowercase two strings by means of LCMapStringEx() and then wcscmp
> the two" always gives the same result as "compare the two strings 
> with CompareStringOrdinal()"

For checking case-insensitive equality, it shouldn't matter whether names are converted to uppercase or lowercase when using invariant non-linguistic casing. It's based on symmetric mappings between pairs of uppercase and lowercase codes, which avoids problems such as 'ϴ' (U+03F4) and 'Θ' (U+0398) both lowercasing as 'θ' (U+03B8), or 'ß' uppercasing as 'SS'.

That said, when sorting filenames, you need to use LCMAP_UPPERCASE in order to match the case-insensitive sort order of Windows. For example, 'Ÿ' (U+0178) is greater than 'Ŷ' (U+0176), but -- respectively lowercase -- 'ÿ' (U+00FF) is less than 'ŷ' (U+0177). In particular, if you have an NTFS directory with two files named 'ÿ' and 'ŷ', the listing will be ['ŷ', 'ÿ'] -- in uppercase order. (An NTFS directory is stored on disk as a b-tree sorted by uppercase filenames.)

For the implementation, _winapi.LCMapStringEx and related constants could be added.
History
Date User Action Args
2020-12-29 15:48:41eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, sogom
2020-12-29 15:48:41eryksunsetmessageid: <1609256921.73.0.993353075096.issue42658@roundup.psfhosted.org>
2020-12-29 15:48:41eryksunlinkissue42658 messages
2020-12-29 15:48:41eryksuncreate