SeString add EncodeWithNullTerminator (#1931)

This commit is contained in:
MidoriKami 2024-07-16 14:32:08 -04:00 committed by GitHub
parent d966e5338a
commit 7f6bbafbbf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -492,6 +492,26 @@ public class SeString
return messageBytes.ToArray();
}
/// <summary>
/// Encodes the Payloads in this SeString into a binary representation
/// suitable for use by in-game handlers, such as the chat log.
/// Includes a null terminator at the end of the string.
/// </summary>
/// <returns>The binary encoded payload data.</returns>
public byte[] EncodeWithNullTerminator()
{
var messageBytes = new List<byte>();
foreach (var p in this.Payloads)
{
messageBytes.AddRange(p.Encode());
}
// Add Null Terminator
messageBytes.Add(0);
return messageBytes.ToArray();
}
/// <summary>
/// Get the text value of this SeString.
/// </summary>