* StreamReader.cs: When detecting the encoding we usually check the
four first bytes looking for either UTF32 or UTF8 BOM, since they share
the first two bytes, but if we happen to have less than 4 bytes at
detection time, just check for Unicode and use it as the current
encoding - this is exactly what .Net does, and it is specially visible
with NetworkStream.
Fixes #534137.
svn path=/trunk/mcs/; revision=150090
+2010-01-23 Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+ * StreamReader.cs: When detecting the encoding we usually check the
+ four first bytes looking for either UTF32 or UTF8 BOM, since they share
+ the first two bytes, but if we happen to have less than 4 bytes at
+ detection time, just check for Unicode and use it as the current
+ encoding - this is exactly what .Net does, and it is specially visible
+ with NetworkStream.
+ Fixes #534137.
+
2010-01-19 Alan McGovern <amcgovern@novell.com>
* BufferedStream.cs: Patch by Tom Philpot to optimise ReadByte and
WriteByte significantly by making them fulfill their request by
this.encoding = Encoding.BigEndianUnicode;
return 2;
}
+ if (input_buffer [0] == 0xff && input_buffer [1] == 0xfe && count < 4) {
+ // If we don't have enough bytes we can't check for UTF32, so use Unicode
+ this.encoding = Encoding.Unicode;
+ return 2;
+ }
if (count < 3)
return 0;