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
public int ByteCount { get; }
Property Value
Encoding
public Encoding Encoding { get; }
Property Value
Value
Set of characters to encode into a span of bytes.
public ReadOnlyMemory<char> Value { get; }
Property Value
Methods
Create(Encoding, ReadOnlyMemory<char>)
Attempts to create a new EncodeableText instance.
[Pure]
public static Result<EncodeableText> Create(Encoding encoding, ReadOnlyMemory<char> value)
Parameters
encodingEncodingEncoding used for encoding the
valueinto a span of bytes.valueReadOnlyMemory<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
encodingEncodingEncoding used for encoding the
valueinto a span of bytes.valuestringstring 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
Returns
ToString()
Returns a string representation of this EncodeableText instance.
[Pure]
public override string ToString()
Returns
- string
String representation.