Table of Contents

Struct EncodeableText

Namespace
LfrlAnvil
Assembly
LfrlAnvil.Core.dll

Allows to safely encode a set of characters into a span of bytes.

public readonly struct EncodeableText
Inherited Members
Extension Methods

Properties

ByteCount

Byte count of the Value to encode, according to the provided Encoding.

public int ByteCount { get; }

Property Value

int

Encoding

Encoding used for encoding the Value into a span of bytes.

public Encoding Encoding { get; }

Property Value

Encoding

Value

Set of characters to encode into a span of bytes.

public ReadOnlyMemory<char> Value { get; }

Property Value

ReadOnlyMemory<char>

Methods

Create(Encoding, ReadOnlyMemory<char>)

Attempts to create a new EncodeableText instance.

[Pure]
public static Result<EncodeableText> Create(Encoding encoding, ReadOnlyMemory<char> value)

Parameters

encoding Encoding

Encoding used for encoding the value into a span of bytes.

value ReadOnlyMemory<char>

Set of characters to encode into a span of bytes.

Returns

Result<EncodeableText>

New EncodeableText instance wrapped in a Result<T> that specifies whether the operation was successful.

Create(Encoding, string)

Attempts to create a new EncodeableText instance.

[Pure]
public static Result<EncodeableText> Create(Encoding encoding, string value)

Parameters

encoding Encoding

Encoding used for encoding the value into a span of bytes.

value string

string to encode into a span of bytes.

Returns

Result<EncodeableText>

New EncodeableText instance wrapped in a Result<T> that specifies whether the operation was successful.

Encode(Span<byte>)

Attempts to encode the Value into the provided span of bytes.

public Result Encode(Span<byte> target)

Parameters

target Span<byte>

Span of bytes to encode the Value into.

Returns

Result

Result instance that specifies whether the operation was successful.

ToString()

Returns a string representation of this EncodeableText instance.

[Pure]
public override string ToString()

Returns

string

String representation.