It may seem like a bug, but it is not....

by Michael S. Kaplan, published on 2005/12/14 13:21 -05:00, original URI:

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...

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:

Thanks! I thought I was nuts...

# Michael S. Kaplan on 14 Dec 2005 9:22 PM:

Nah, not nuts at all. But I would prescribe reading this blog once a week and enter comments prn (as needed).


# CornedBee on 15 Dec 2005 3:45 AM:

On a stylistic note, you might want to use tinyurl or a similar service for URLs such as these.

# Michael S. Kaplan on 15 Dec 2005 3:47 AM:

It wasn't my URL, it was IDisposable's. Anyone can click on it right from the blog page. :-)

Once you see it you'll ealixe you do not need to save the reference....

# Michael S. Kaplan on 15 Dec 2005 3:49 AM:

It looks like the post was removed anyway. I guess someone decided I was correct. :-)

# Anutthara MSFT on 15 Dec 2005 3:58 AM:

Clicking on the URL gives me:
This feedback is not being displayed because it has been deemed as inappropriate content. Please refer to the FAQ for more details.

If you think this happened by mistake, please use the Contact Us link in the footer.

# Michael S. Kaplan on 15 Dec 2005 4:00 AM:

Thats what I mean, Anutthara -- the post is gone now. I assume IDisposable took it down (there are four other posts with an author by that name, but this one has disappeared).

go to newer or older post, or back to index or month or day