59 references to SupportedEncoding
System.Private.DataContractSerialization (59)
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)
116private void SetReadDocumentEncoding(SupportedEncoding e)
123private static Encoding GetEncoding(SupportedEncoding e) =>
126SupportedEncoding.UTF8 => DataContractSerializer.ValidatingUTF8,
127SupportedEncoding.UTF16LE => DataContractSerializer.ValidatingUTF16,
128SupportedEncoding.UTF16BE => DataContractSerializer.ValidatingBEUTF16,
132private static Encoding GetSafeEncoding(SupportedEncoding e) =>
135SupportedEncoding.UTF8 => DataContractSerializer.UTF8NoBom,
136SupportedEncoding.UTF16LE => DataContractSerializer.UTF16NoBom,
137SupportedEncoding.UTF16BE => DataContractSerializer.BEUTF16NoBom,
141private static string GetEncodingName(SupportedEncoding enc) =>
144SupportedEncoding.UTF8 => "utf-8",
145SupportedEncoding.UTF16LE => "utf-16LE",
146SupportedEncoding.UTF16BE => "utf-16BE",
150private static SupportedEncoding GetSupportedEncoding(Encoding? encoding)
153return SupportedEncoding.None;
155return SupportedEncoding.UTF8;
157return SupportedEncoding.UTF16LE;
159return SupportedEncoding.UTF16BE;
174if (_encodingCode != SupportedEncoding.UTF8)
191private SupportedEncoding ReadBOMEncoding(bool notOutOfBand)
203SupportedEncoding e = ReadBOMEncoding((byte)b1, (byte)b2, (byte)b3, (byte)b4, notOutOfBand, out preserve);
229private static SupportedEncoding ReadBOMEncoding(byte b1, byte b2, byte b3, byte b4, bool notOutOfBand, out int preserve)
231SupportedEncoding e = SupportedEncoding.UTF8; // Default
236e = SupportedEncoding.UTF8;
241e = SupportedEncoding.UTF16LE;
246e = SupportedEncoding.UTF16BE;
251e = SupportedEncoding.UTF16BE;
259e = SupportedEncoding.UTF16LE;
308private static void CheckUTF8DeclarationEncoding(byte[] buffer, int offset, int count, SupportedEncoding e, SupportedEncoding expectedEnc)
350if (e != SupportedEncoding.UTF8 && expectedEnc == SupportedEncoding.None)
364if (e != SupportedEncoding.UTF8 && expectedEnc == SupportedEncoding.None)
387SupportedEncoding declEnc = e;
390declEnc = SupportedEncoding.UTF8;
394declEnc = SupportedEncoding.UTF16LE;
398declEnc = SupportedEncoding.UTF16BE;
402if (e == SupportedEncoding.UTF8)
442SupportedEncoding expectedEnc = GetSupportedEncoding(encoding);
443SupportedEncoding declEnc = ReadBOMEncoding(buffer[offset], buffer[offset + 1], buffer[offset + 2], buffer[offset + 3], encoding == null, out preserve);
444if (expectedEnc != SupportedEncoding.None && expectedEnc != declEnc)
454if (declEnc == SupportedEncoding.UTF8)
484if (expectedEnc == SupportedEncoding.None)
497private static void ThrowExpectedEncodingMismatch(SupportedEncoding expEnc, SupportedEncoding actualEnc)
502private static void ThrowEncodingMismatch(string declEnc, SupportedEncoding enc)
577if (_byteCount == 0 && _encodingCode == SupportedEncoding.UTF8)
593if (_encodingCode == SupportedEncoding.UTF8)
650if (_encodingCode == SupportedEncoding.UTF16LE)
677if (_encodingCode == SupportedEncoding.UTF8)
689if (_encodingCode == SupportedEncoding.UTF8)