Struct VBRuntimeByteStringValue
The runtime value of a String whose data is an odd number of bytes: the whole characters it holds, and the byte
left over after them.
public readonly record struct VBRuntimeByteStringValue : IRuntimeValue<string>, IRuntimeValue, IEquatable<VBRuntimeByteStringValue>
- Implements
- Inherited Members
Remarks
The binary format a String is stored in is "the implementation-defined binary format used to store String
data" (MS-VBAL §5.5.1.2.6), and a Byte() of any length is "interpreted as if it represents" it.
RDCore's format is UTF-16LE code units - which a managed string already is - and, when the data is an odd
number of bytes, the one byte left over after the last whole code unit. A string cannot hold half a code
unit, so that byte is held beside it.
👉 Only an odd string is one of these: an even one is the VBRuntimeValue<T> of a string it always was. BoxedValue is the whole characters, so a reader that only knows the managed value sees the characters of an odd string - never nothing, and never half a character.
The byte image assumes a little-endian platform that allows misaligned access, as the session's memory already does.
Constructors
VBRuntimeByteStringValue(string, byte)
The runtime value of a String whose data is an odd number of bytes: the whole characters it holds, and the byte
left over after them.
public VBRuntimeByteStringValue(string Text, byte TrailingByte)
Parameters
TextstringThe whole characters: every code unit the data makes up.
TrailingBytebyteThe byte left over after them.
Remarks
The binary format a String is stored in is "the implementation-defined binary format used to store String
data" (MS-VBAL §5.5.1.2.6), and a Byte() of any length is "interpreted as if it represents" it.
RDCore's format is UTF-16LE code units - which a managed string already is - and, when the data is an odd
number of bytes, the one byte left over after the last whole code unit. A string cannot hold half a code
unit, so that byte is held beside it.
👉 Only an odd string is one of these: an even one is the VBRuntimeValue<T> of a string it always was. BoxedValue is the whole characters, so a reader that only knows the managed value sees the characters of an odd string - never nothing, and never half a character.
The byte image assumes a little-endian platform that allows misaligned access, as the session's memory already does.
Properties
BoxedValue
public object BoxedValue { get; }
Property Value
StoredValue
public string StoredValue { get; }
Property Value
Text
The whole characters: every code unit the data makes up.
public string Text { get; init; }
Property Value
TrailingByte
The byte left over after them.
public byte TrailingByte { get; init; }
Property Value
Methods
BytesOf(IRuntimeValue)
The data of the String value holds: two bytes per code unit, little-endian, then the trailing
byte when there is one.
public static byte[] BytesOf(IRuntimeValue value)
Parameters
valueIRuntimeValueThe runtime value of a
String.
Returns
- byte[]
Remarks
vbNullString has no data at all, and neither has a value that holds no String.
FromBytes(ReadOnlySpan<byte>)
The runtime value of the String whose data is bytes: an ordinary one for an even number of
bytes, and one of these for an odd number.
public static IRuntimeValue<string> FromBytes(ReadOnlySpan<byte> bytes)
Parameters
bytesReadOnlySpan<byte>The data of the string, two bytes per code unit, little-endian.
Returns
Remarks
Every byte is kept, and every pair of bytes is a code unit - a lone surrogate included. Encoding.Unicode is not
this format: it reads 00 D8 as U+FFFD and drops an odd byte.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.