EncodingWithoutPreamble
using System;
using System.Runtime.CompilerServices;
using System.Text;
namespace DotNext.Text
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class EncodingWithoutPreamble : Encoding
{
private readonly Encoding encoding;
[System.Runtime.CompilerServices.Nullable(0)]
public override ReadOnlySpan<byte> Preamble {
[System.Runtime.CompilerServices.NullableContext(0)]
get {
return default(ReadOnlySpan<byte>);
}
}
public override string BodyName => encoding.BodyName;
public override int CodePage => encoding.CodePage;
public override string EncodingName => encoding.EncodingName;
public override string HeaderName => encoding.HeaderName;
public override int WindowsCodePage => encoding.WindowsCodePage;
public override string WebName => encoding.WebName;
public override bool IsSingleByte => encoding.IsSingleByte;
public override bool IsBrowserDisplay => encoding.IsBrowserDisplay;
public override bool IsBrowserSave => encoding.IsBrowserSave;
public override bool IsMailNewsDisplay => encoding.IsMailNewsDisplay;
public override bool IsMailNewsSave => encoding.IsMailNewsSave;
private EncodingWithoutPreamble(Encoding enc)
: base(enc.WindowsCodePage, enc.EncoderFallback, enc.DecoderFallback)
{
encoding = enc;
}
internal static Encoding Create(Encoding enc)
{
return new EncodingWithoutPreamble(enc);
}
public override byte[] GetPreamble()
{
return Array.Empty<byte>();
}
public override int GetByteCount(char[] chars, int index, int count)
{
return encoding.GetByteCount(chars, index, count);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public override int GetByteCount(ReadOnlySpan<char> chars)
{
return encoding.GetByteCount(chars);
}
public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
return encoding.GetBytes(chars, charIndex, charCount, bytes, byteIndex);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public override int GetBytes(ReadOnlySpan<char> chars, Span<byte> bytes)
{
return encoding.GetBytes(chars, bytes);
}
public override int GetCharCount(byte[] bytes, int index, int count)
{
return encoding.GetCharCount(bytes, index, count);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public override int GetCharCount(ReadOnlySpan<byte> bytes)
{
return encoding.GetCharCount(bytes);
}
public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
return encoding.GetChars(bytes, byteIndex, byteCount, chars, charIndex);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public override int GetChars(ReadOnlySpan<byte> bytes, Span<char> chars)
{
return encoding.GetChars(bytes, chars);
}
public override int GetMaxByteCount(int charCount)
{
return encoding.GetMaxByteCount(charCount);
}
public override int GetMaxCharCount(int byteCount)
{
return encoding.GetMaxCharCount(byteCount);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public unsafe override int GetByteCount(char* chars, int count)
{
return encoding.GetByteCount(chars, count);
}
public override int GetByteCount(char[] chars)
{
return encoding.GetByteCount(chars);
}
public override int GetByteCount(string s)
{
return encoding.GetByteCount(s);
}
public override byte[] GetBytes(char[] chars)
{
return encoding.GetBytes(chars);
}
public override object Clone()
{
return new EncodingWithoutPreamble(encoding);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
{
return encoding.GetBytes(chars, charCount, bytes, byteCount);
}
public override byte[] GetBytes(char[] chars, int index, int count)
{
return encoding.GetBytes(chars, index, count);
}
public override byte[] GetBytes(string s)
{
return encoding.GetBytes(s);
}
public override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
return encoding.GetBytes(s, charIndex, charCount, bytes, byteIndex);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public unsafe override int GetCharCount(byte* bytes, int count)
{
return encoding.GetCharCount(bytes, count);
}
public override int GetCharCount(byte[] bytes)
{
return encoding.GetCharCount(bytes);
}
[System.Runtime.CompilerServices.NullableContext(0)]
public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
{
return encoding.GetChars(bytes, byteCount, chars, charCount);
}
public override char[] GetChars(byte[] bytes)
{
return encoding.GetChars(bytes);
}
public override bool IsAlwaysNormalized(NormalizationForm form)
{
return encoding.IsAlwaysNormalized(form);
}
public override char[] GetChars(byte[] bytes, int index, int count)
{
return encoding.GetChars(bytes, index, count);
}
public override Decoder GetDecoder()
{
return encoding.GetDecoder();
}
public override Encoder GetEncoder()
{
return encoding.GetEncoder();
}
public override string GetString(byte[] bytes)
{
return encoding.GetString(bytes);
}
public override string GetString(byte[] bytes, int index, int count)
{
return encoding.GetString(bytes, index, count);
}
public override string ToString()
{
return encoding.ToString();
}
[System.Runtime.CompilerServices.NullableContext(2)]
public override bool Equals(object other)
{
EncodingWithoutPreamble encodingWithoutPreamble = other as EncodingWithoutPreamble;
if (encodingWithoutPreamble == null)
return encoding.Equals(other);
return encoding.Equals(encodingWithoutPreamble.encoding);
}
public override int GetHashCode()
{
return encoding.GetHashCode();
}
}
}