Replace U+202F with Indent payload (#1761)

* Replace U+202F with Indent payload

* comment

---------

Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
Infi 2024-04-10 00:33:19 +02:00 committed by GitHub
parent 84abd23ad5
commit c8f65e24f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,9 +155,29 @@ internal sealed unsafe class ChatGui : IInternalDisposableService, IChatGui
while (this.chatQueue.Count > 0)
{
var chat = this.chatQueue.Dequeue();
var replacedMessage = new SeStringBuilder();
// Normalize Unicode NBSP to the built-in one, as the former won't renderl
foreach (var payload in chat.Message.Payloads)
{
if (payload is TextPayload { Text: not null } textPayload)
{
var split = textPayload.Text.Split("\u202f"); // NARROW NO-BREAK SPACE
for (var i = 0; i < split.Length; i++)
{
replacedMessage.AddText(split[i]);
if (i + 1 < split.Length)
replacedMessage.Add(new RawPayload([0x02, (byte)Lumina.Text.Payloads.PayloadType.Indent, 0x01, 0x03]));
}
}
else
{
replacedMessage.Add(payload);
}
}
var sender = Utf8String.FromSequence(chat.Name.Encode());
var message = Utf8String.FromSequence(chat.Message.Encode());
var message = Utf8String.FromSequence(replacedMessage.BuiltString.Encode());
this.HandlePrintMessageDetour(RaptureLogModule.Instance(), chat.Type, sender, message, (int)chat.SenderId, (byte)(chat.Parameters != 0 ? 1 : 0));