YamlEncodedText struct
Provides a way to transform UTF-8 or UTF-16 encoded text into a form that is suitable for YAML.
Namespace: System.Text.Yaml ยท Assembly: Styml.dll
public readonly struct YamlEncodedText : IEquatable<YamlEncodedText>
Implements: IEquatable<YamlEncodedText>
Provides a way to transform UTF-8 or UTF-16 encoded text into a form that is suitable for YAML.
RemarksLink to this heading
This can be used to cache and store known strings used for writing YAML ahead of time by pre-encoding them up front.
PropertiesLink to this heading
EncodedUtf8BytesLink to this heading
Returns the UTF-8 encoded representation of the pre-encoded YAML text.
public ReadOnlySpan<byte> EncodedUtf8Bytes { get; }
ValueLink to this heading
Returns the UTF-16 encoded representation of the pre-encoded YAML text as a String.
public string Value { get; }
MethodsLink to this heading
EncodeLink to this heading
Encodes the string text value as a YAML string.
public static YamlEncodedText Encode(string value, JavaScriptEncoder? encoder = null);
Parameters
value: The value to be transformed as YAML encoded text.encoder: The encoder to use when escaping the string, ornullto use the default encoder.
| Exception | Condition |
|---|---|
| ArgumentNullException | Thrown if value is null. |
| ArgumentException | Thrown when the specified value is too large or if it contains invalid UTF-16 characters. |
Encodes the text value as a YAML string.
public static YamlEncodedText Encode(ReadOnlySpan<char> value, JavaScriptEncoder? encoder = null);
Parameters
value: The value to be transformed as YAML encoded text.encoder: The encoder to use when escaping the string, ornullto use the default encoder.
| Exception | Condition |
|---|---|
| ArgumentException | Thrown when the specified value is too large or if it contains invalid UTF-16 characters. |
Encodes the UTF-8 text value as a YAML string.
public static YamlEncodedText Encode(ReadOnlySpan<byte> utf8Value, JavaScriptEncoder? encoder = null);
Parameters
utf8Value: The UTF-8 encoded value to be transformed as YAML encoded text.encoder: The encoder to use when escaping the string, ornullto use the default encoder.
| Exception | Condition |
|---|---|
| ArgumentException | Thrown when the specified value is too large or if it contains invalid UTF-8 bytes. |
EqualsLink to this heading
Determines whether this instance and another specified YamlEncodedText instance have the same value.
public bool Equals(YamlEncodedText other);
Default instances of YamlEncodedText are treated as equal.
Determines whether this instance and a specified object, which must also be a YamlEncodedText instance, have the same value.
public override bool Equals(object? obj);
If obj is null, the method returns false.
GetHashCodeLink to this heading
Returns the hash code for this YamlEncodedText.
public override int GetHashCode();
Returns 0 on a default instance of YamlEncodedText.
ToStringLink to this heading
Converts the value of this instance to a String.
public override string ToString();
Returns: Returns the underlying UTF-16 encoded string.
Returns an empty string on a default instance of YamlEncodedText.