[Mono-devel-list] Mono code using Char.ToUpper/ ToLower in bad shape
Andreas Nahr
ClassDevelopment at A-SoftTech.com
Sat Apr 24 05:34:35 EDT 2004
Hi,
we have bug in our class libraries. Right now Char.ToUpper()/ ToLower()
return an Invariant culture result. However according to the specs we should
return the result for the current locale.
The problem is that lots of code in the BCL DEPEND on this behavior. The
classical situation where two bugs eliminate each other.
I just check through corlib and it seems that all calls to Char.ToUpper() or
ToLower() actually WANT/NEED to call the invariant version.
So somebody needs to check through ALL libraries an look where ToUpper() and
ToLower() is used and replace this.
For all libraries except corlib this should be done calling Char.ToUpper
(CultureInfo.InvariantCulture).
For corlib I would suggest adding an internal function
Char.ToUpperInvariant() which should be called (Would be a little bit faster
because it can skip two checks, which is important because at places
Char.ToUpper is used in loops)
And if we are already at BAD programing style:
If you see something like:
if (string1.ToLower() == string2.ToLower())
PLEASE replace it immediately. This is extremely bad code and slow as hell.
Just tell .Net what you want to do:
if (String.Compare (string1, string2, true) == 0)
in most cases you probably want to do:
if (String.Compare (string1, string2, true, CultureInfo.InvariantCulture) ==
0)
More information about the Mono-devel-list
mailing list