The Mono implementation of Decoder.Convert() method differs from the Microsoft .NET implementation and of its expected behaviour.
If we read the following byte stream with the microsoft implementation:
0x20 0xC3 0xA1 0xC3 0xA9
- byte 0x20 and character ' '
- bytes 0xC3 0xA1 and character 'á'
- bytes 0xC3 0xA9 and character 'é'
But with the same code (or binary) using the mono class libraries we obtain the following behaviour:
- byte 0x20 0xC3 and get the char ' ' (?)
- bytes 0xA1 0xC3 and we get tha char 'á' (???)
- byte 0xA9 and now we got 'é' (??WHAT??)
It seems that the Mono implementation of Convert is broken twice:
- it does not honour the 'flush()' flag -- which makes possible to decode the shown byte stream in this way
- and consumes more bytes of needed when is decoding a one-byte utf8 char.
I attach a simple test with the output of the Microsoft .NET execution (msnet) and the output of the same binary running under Mono. The binary is compiled with the 'mono-csc' compiler.
Created attachment 3482 [details]
a test case with the different behaviour seen in Mono and MS.NET
I ran the use case with mono 4.2, and the output was now identical to the one generated in .NET.