0

I'm trying to get the relationship between results of string comparison when using StringComparer.OrdinalignoreCase and StringComparer.InvariantCultureIgnoreCase. More precisely I would like to know which of the following four statements is true:

  1. a == b using StringComparer.OrdinalIgnoreCase, then a == b using StringComparer.InvariantCultureIgnoreCase
  2. a != b using StringComparer.OrdinalIgnoreCase, then a != b using StringComparer.InvariantCultureIgnoreCase
  3. a == b using StringComparer.InvariantCultureIgnoreCase, then a == b using StringComparer.OrdinalIgnoreCase
  4. a != b using StringComparer.InvariantCultureIgnoreCase, then a != b using StringComparer.OrdinalIgnoreCase

So far I know statement number 3 is not true because of the example of a = STRASSE and b = Straße from a comment in this question.

Ideally I would like to have an explanation why a statement is true or an example when it is not true.

Community
  • 1
  • 1
Bartłomiej Siwek
  • 1,447
  • 2
  • 17
  • 26
  • I don't believe any of those statements to be true for all inputs. However, the result of the `==` and `!=` relations for any particular string is guaranteed to be stable because ordinal on the one hand is simply a comparison of an array of ushort values (except for case ignorance) and the invariant culture on the other is guaranteed not to change across cultures and .NET versions. – 500 - Internal Server Error Oct 21 '14 at 00:28

1 Answers1

0

The difference between Ordinal and Invariant collation is the difference between non-linguistic and linguistic collation.

In theory 1 should be true (it is if you do not ignore case) but the casing rules are different when you use non-linguistic casing and linguistic casing. The rest are false.

Eric MSFT
  • 3,246
  • 1
  • 18
  • 28