fix payload parsing to not use PeekChar() when it actually wants a byte (breaks in some non-ascii cases)

This commit is contained in:
meli 2020-04-26 14:38:28 -07:00
parent dee30b5655
commit 52a2ccf31a
2 changed files with 11 additions and 4 deletions

View file

@ -30,7 +30,10 @@ namespace Dalamud.Game.Chat.SeStringHandling
public static Payload Process(BinaryReader reader)
{
Payload payload = null;
if ((byte)reader.PeekChar() != START_BYTE)
var initialByte = reader.ReadByte();
reader.BaseStream.Position--;
if (initialByte != START_BYTE)
{
payload = ProcessText(reader);
}

View file

@ -58,11 +58,15 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
while (reader.BaseStream.Position < endOfStream)
{
if ((byte)reader.PeekChar() == START_BYTE)
var nextByte = reader.ReadByte();
if (nextByte == START_BYTE)
{
// rewind since this byte isn't part of this payload
reader.BaseStream.Position--;
break;
}
// not the most efficient, but the easiest
text.Add(reader.ReadByte());
text.Add(nextByte);
}
if (text.Count > 0)