Case insensitive compare of single characters

  • Thread starter Thread starter Coder Guy
  • Start date Start date
C

Coder Guy

Is it possible to do a case insensitive comparison of individual characters?
I tried:

Char.ToLowerInvariant(charA).CompareTo(Char.ToLowerInvariant(charB))

And though it works for the most part, it didn't seem to work for all
locales.

I tried converting the characters to a string and then do a case insensitive
comparison, and this always worked. Unfortunately this comparison is being
called millions of times and converting to a string is terribly inefficient.
Do I have any other options?

Thanks
 
Coder Guy said:
Is it possible to do a case insensitive comparison of individual
characters? I tried:

Char.ToLowerInvariant(charA).CompareTo(Char.ToLowerInvariant(charB))

And though it works for the most part, it didn't seem to work for all
locales.

Can you say, where it doesn't work?

Since ToLowerInvariant aswell as CompareTo are culture invariant, the result
shouldn't depend on the locale

Christof
 
Back
Top