by Michael S. Kaplan, published on 2005/12/14 13:21 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/12/14/503674.aspx
A user with the amusing handle of IDisposable asked me the following question via the contact link:
Title: Am I nuts?
Could you check this Ladybug report for me? I think it is bad code, but I'm not versed enough in the String.Compare(x,x,x,x,StringComparison.OrdinalIngoreCase) to be sure...http://lab.msdn.microsoft.com/ProductFeedback/viewfeedback.aspx?feedbackid=5bb29e79-abdd-45e1-b431-6bf3ec52c35f
Well, I don't think IDisposable is nuts, but he is incorrect.
As I have often stated here, Ordinal comparisons are binary ones, not language specific ones.
And OrdinalIgnoreCase is not ignoring case in a language-specific way, so there is no way that language differences can affect the casing part of the operation.
To make a further somewhat related point, currently in Microsoft products there is no casing operation that will change the length of a string -- the casing tables map one UTF-16 code unit to another, and even in .NET where casing of supplementary characters has been added, you always convert two UTF-16 code code units to two other ones. So the length will remain constant.
Of course linguistic comparisons do a bit more than that (as I pointed out in this post and this one, too), not to mention issues such as Unicode canonical equivalance that definitely let different length strings be equal. But neither Ordinal nor OrdinalIgnoreCase comparisons do anything like that....
This post sponsored by "ß" (U+00df, LATIN SMALL LETTER SHARP S)
# IDisposable on 14 Dec 2005 9:04 PM:
# Michael S. Kaplan on 14 Dec 2005 9:22 PM:
# CornedBee on 15 Dec 2005 3:45 AM:
# Michael S. Kaplan on 15 Dec 2005 3:47 AM:
# Michael S. Kaplan on 15 Dec 2005 3:49 AM:
# Anutthara MSFT on 15 Dec 2005 3:58 AM:
# Michael S. Kaplan on 15 Dec 2005 4:00 AM:
go to newer or older post, or back to index or month or day