From 7f6bbafbbfc3f5951281d62fa36dd9a6895ad8e7 Mon Sep 17 00:00:00 2001 From: MidoriKami <9083275+MidoriKami@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:32:08 -0400 Subject: [PATCH] SeString add EncodeWithNullTerminator (#1931) --- .../Game/Text/SeStringHandling/SeString.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Dalamud/Game/Text/SeStringHandling/SeString.cs b/Dalamud/Game/Text/SeStringHandling/SeString.cs index 4a04f0326..03e6e1078 100644 --- a/Dalamud/Game/Text/SeStringHandling/SeString.cs +++ b/Dalamud/Game/Text/SeStringHandling/SeString.cs @@ -492,6 +492,26 @@ public class SeString return messageBytes.ToArray(); } + /// + /// 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. + /// + /// The binary encoded payload data. + public byte[] EncodeWithNullTerminator() + { + var messageBytes = new List(); + foreach (var p in this.Payloads) + { + messageBytes.AddRange(p.Encode()); + } + + // Add Null Terminator + messageBytes.Add(0); + + return messageBytes.ToArray(); + } + /// /// Get the text value of this SeString. ///