private static readonly byte[] s_bigEndianPreamble = new byte[4] { 0x00, 0x00, 0xFE, 0xFF };
private static readonly byte[] s_littleEndianPreamble = new byte[4] { 0xFF, 0xFE, 0x00, 0x00 };
- private bool _emitUTF32ByteOrderMark = false;
- private bool _isThrowException = false;
- private bool _bigEndian = false;
+ private readonly bool _emitUTF32ByteOrderMark = false;
+ private readonly bool _isThrowException = false;
+ private readonly bool _bigEndian = false;
- public UTF32Encoding() : this(false, true, false)
+ public UTF32Encoding() : this(false, true)
{
}
public UTF32Encoding(bool bigEndian, bool byteOrderMark) :
- this(bigEndian, byteOrderMark, false)
+ base(bigEndian ? 12001 : 12000)
{
+ _bigEndian = bigEndian;
+ _emitUTF32ByteOrderMark = byteOrderMark;
}
public UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters) :
- base(bigEndian ? 12001 : 12000)
+ this(bigEndian, byteOrderMark)
{
- _bigEndian = bigEndian;
- _emitUTF32ByteOrderMark = byteOrderMark;
_isThrowException = throwOnInvalidCharacters;
// Encoding constructor already did this, but it'll be wrong if we're throwing exceptions
// the standard.
internal readonly bool _emitUTF8Identifier = false;
- private bool _isThrowException = false;
+ private readonly bool _isThrowException = false;
public UTF8Encoding() : this(false)
public UTF8Encoding(bool encoderShouldEmitUTF8Identifier) :
- this(encoderShouldEmitUTF8Identifier, false)
+ base(UTF8_CODEPAGE)
{
+ _emitUTF8Identifier = encoderShouldEmitUTF8Identifier;
}
public UTF8Encoding(bool encoderShouldEmitUTF8Identifier, bool throwOnInvalidBytes) :
- base(UTF8_CODEPAGE)
+ this(encoderShouldEmitUTF8Identifier)
{
- _emitUTF8Identifier = encoderShouldEmitUTF8Identifier;
_isThrowException = throwOnInvalidBytes;
// Encoding's constructor already did this, but it'll be wrong if we're throwing exceptions
private static readonly byte[] s_bigEndianPreamble = new byte[2] { 0xfe, 0xff };
private static readonly byte[] s_littleEndianPreamble = new byte[2] { 0xff, 0xfe };
- private bool isThrowException = false;
+ private readonly bool isThrowException = false;
- private bool bigEndian = false;
- private bool byteOrderMark = true;
+ private readonly bool bigEndian = false;
+ private readonly bool byteOrderMark = false;
// Unicode version 2.0 character size in bytes
public const int CharSize = 2;
public UnicodeEncoding(bool bigEndian, bool byteOrderMark)
- : this(bigEndian, byteOrderMark, false)
+ : base(bigEndian ? 1201 : 1200) //Set the data item.
{
+ this.bigEndian = bigEndian;
+ this.byteOrderMark = byteOrderMark;
}
public UnicodeEncoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
- : base(bigEndian ? 1201 : 1200) //Set the data item.
+ : this(bigEndian, byteOrderMark)
{
this.isThrowException = throwOnInvalidBytes;
- this.bigEndian = bigEndian;
- this.byteOrderMark = byteOrderMark;
// Encoding constructor already did this, but it'll be wrong if we're throwing exceptions
if (this.isThrowException)