FrameworkFork\System.Runtime.Serialization\System\Xml\EncodingStreamWrapper.cs (59)
39private SupportedEncoding _encodingCode;
62SupportedEncoding expectedEnc = GetSupportedEncoding(encoding);
66SupportedEncoding declEnc = ReadBOMEncoding(encoding == null);
69if (expectedEnc != SupportedEncoding.None && expectedEnc != declEnc)
73if (declEnc == SupportedEncoding.UTF8)
104if (expectedEnc == SupportedEncoding.None)
115private void SetReadDocumentEncoding(SupportedEncoding e)
122private static Encoding GetEncoding(SupportedEncoding e)
126case SupportedEncoding.UTF8:
129case SupportedEncoding.UTF16LE:
132case SupportedEncoding.UTF16BE:
140private static Encoding GetSafeEncoding(SupportedEncoding e)
144case SupportedEncoding.UTF8:
147case SupportedEncoding.UTF16LE:
150case SupportedEncoding.UTF16BE:
158private static string GetEncodingName(SupportedEncoding enc)
162case SupportedEncoding.UTF8:
165case SupportedEncoding.UTF16LE:
168case SupportedEncoding.UTF16BE:
176private static SupportedEncoding GetSupportedEncoding(Encoding encoding)
179return SupportedEncoding.None;
181return SupportedEncoding.UTF8;
183return SupportedEncoding.UTF16LE;
185return SupportedEncoding.UTF16BE;
200if (_encodingCode != SupportedEncoding.UTF8)
216private SupportedEncoding ReadBOMEncoding(bool notOutOfBand)
228SupportedEncoding e = ReadBOMEncoding((byte)b1, (byte)b2, (byte)b3, (byte)b4, notOutOfBand, out preserve);
254private static SupportedEncoding ReadBOMEncoding(byte b1, byte b2, byte b3, byte b4, bool notOutOfBand, out int preserve)
256SupportedEncoding e = SupportedEncoding.UTF8; // Default
261e = SupportedEncoding.UTF8;
266e = SupportedEncoding.UTF16LE;
271e = SupportedEncoding.UTF16BE;
276e = SupportedEncoding.UTF16BE;
284e = SupportedEncoding.UTF16LE;
336private static void CheckUTF8DeclarationEncoding(byte[] buffer, int offset, int count, SupportedEncoding e, SupportedEncoding expectedEnc)
378if (e != SupportedEncoding.UTF8 && expectedEnc == SupportedEncoding.None)
392if (e != SupportedEncoding.UTF8 && expectedEnc == SupportedEncoding.None)
415SupportedEncoding declEnc = e;
418declEnc = SupportedEncoding.UTF8;
422declEnc = SupportedEncoding.UTF16LE;
426declEnc = SupportedEncoding.UTF16BE;
430if (e == SupportedEncoding.UTF8)
480SupportedEncoding expectedEnc = GetSupportedEncoding(encoding);
481SupportedEncoding declEnc = ReadBOMEncoding(buffer[offset], buffer[offset + 1], buffer[offset + 2], buffer[offset + 3], encoding == null, out preserve);
482if (expectedEnc != SupportedEncoding.None && expectedEnc != declEnc)
492if (declEnc == SupportedEncoding.UTF8)
522if (expectedEnc == SupportedEncoding.None)
535private static void ThrowExpectedEncodingMismatch(SupportedEncoding expEnc, SupportedEncoding actualEnc)
540private static void ThrowEncodingMismatch(string declEnc, SupportedEncoding enc)
611if (_byteCount == 0 && _encodingCode == SupportedEncoding.UTF8)
624if (_encodingCode == SupportedEncoding.UTF8)
674if (_encodingCode == SupportedEncoding.UTF16LE)
701if (_encodingCode == SupportedEncoding.UTF8)
713if (_encodingCode == SupportedEncoding.UTF8)