DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.0.0-beta.7" />

 EncodingExtensions

public static class EncodingExtensions
Represents extension method for Encoding data type.
public static MemoryOwner<byte> GetBytes(this Encoding encoding, ReadOnlySpan<char> chars, MemoryAllocator<byte> allocator = null)

Encodes a set of characters from the specified read-only span.

public static MemoryOwner<char> GetChars(this Encoding encoding, ReadOnlySpan<byte> bytes, MemoryAllocator<char> allocator = null)

Decodes all the bytes in the specified read-only byte.

public static Encoding WithoutPreamble(this Encoding encoding)

Returns Encoding that doesn't generate BOM.