[Mono-dev] String.Compare bug

Nicklas Overgaard nicklas at isharp.dk
Wed Apr 13 14:52:00 EDT 2011

Hi again,

The previously attached patch does not apply for some reason. A new one
is attached here.

Sorry about that.


On Wed, 2011-04-13 at 18:05 +0200, Nicklas Overgaard wrote:
> Hi mono devers!
> I discovered a bug in String.Compare when using a UTF8 string created
> from a byte array with a zero-byte at the end. It's converted to the
> same string on both .net and mono, however, String.Compare on .net is
> different from String.Compare on mono.
> The issue is the following:
> Mono reports "1" on the string compare, signaling that the converted
> string is "larger" than the hard-coded string I compare it to. And it
> kinda is - the byte array is converted to "%EOF\0" and the hardcoded
> string is just "%EOF" - but .net manages to ignore the '\0' when doing
> the compare, which results in "0" (equal strings).
> Attached is a patch, which adds a test-case to
> 'mcs/class/corlib/Test/System' which shows the issue -
> "CompareNotWorking3" to follow the lingo :)
> I have tried to track the issue down myself in String.Compare, but I
> gave up due to the complexity of the underlying code.
> As a final note, I'm running with UTF8 culture on my Linux box, where
> the issue is showing up.
> Best regards,
> Nicklas Overgaard
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

-------------- next part --------------
A non-text attachment was scrubbed...
Name: string-compare-test.patch
Type: text/x-patch
Size: 748 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110413/887277e0/attachment.bin 

More information about the Mono-devel-list mailing list