DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="5.0.2" />

 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 span.

public static Encoding WithoutPreamble(this Encoding encoding)

Returns Encoding that doesn't generate BOM.