TextEncoder Class

https://encoding.spec.whatwg.org/#interface-textencoder

public sealed class TextEncoder

Constructors

NameDescription
TextEncoder()Creates a UTF-8 encoder.

TextEncoder()

TextDecoder.cs

Creates a UTF-8 encoder.

public TextEncoder()

Properties

NameDescription
EncodingGets the name of the encoding, which is always utf-8.

Gets the name of the encoding, which is always utf-8.

public string Encoding { get; }

Methods

NameDescription
Encode(string)Returns the UTF-8 bytes of the given string.
EncodeInto(string, Span<byte>)Encodes the given string as UTF-8 into the destination and returns the number of units read and bytes written.

Encode(string)

TextDecoder.cs

Returns the UTF-8 bytes of the given string.

public byte[] Encode(string input = "")

EncodeInto(string, Span<byte>)

TextDecoder.cs

Encodes the given string as UTF-8 into the destination and returns the number of units read and bytes written.

public TextEncoderEncodeIntoResult EncodeInto(string source, Span<byte> destination)