From b916b06c03d7dfc293e79fe6462f5fb7b732ae0f Mon Sep 17 00:00:00 2001 From: abcboy101 <16735361+abcboy101@users.noreply.github.com> Date: Mon, 27 Jul 2026 12:14:13 -0400 Subject: [PATCH] PBR: Fix SetStringUnicodeBR maxLength (#4843) maxLength is the maximum length in terms of characters, not bytes --- PKHeX.Core/PKM/Strings/StringConverter4GC.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/PKM/Strings/StringConverter4GC.cs b/PKHeX.Core/PKM/Strings/StringConverter4GC.cs index b724d6f42..efc1eb294 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter4GC.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter4GC.cs @@ -208,17 +208,17 @@ public static int LoadStringUnicodeBR(ReadOnlySpan data, Span result public static int SetStringUnicodeBR(ReadOnlySpan value, Span destBuffer, int maxLength = -1, StringConverterOption option = StringConverterOption.ClearZero) { if (maxLength < 0) - maxLength = destBuffer.Length - 2; + maxLength = (destBuffer.Length / 2) - 1; if (option is StringConverterOption.ClearZero) destBuffer.Clear(); int count = 0; - for (int i = 0; i < value.Length && count < maxLength; i++) + for (int i = 0; i < value.Length && count < maxLength * 2; i++) { var c = value[i]; if (c is LineBreak or Proportional or PokemonName) { - if (count + 2 >= maxLength) + if (count + 2 >= maxLength * 2) break; WriteUInt16BigEndian(destBuffer[count..], VariableChar); count += 2;