Fix pk1/pk2 char conversion to >=pk7 (#4545)

* Fix pk1/pk2 char conversion to >=pk7

Fixed conversion of a gen1/2 "․" to ASCII "." when converting to pk7 or newer.
Added a test that verifies the fix.

Addresses the issue: https://github.com/kwsch/PKHeX/issues/4543

* Update StringTests.cs
This commit is contained in:
drabu96 2025-08-15 20:30:07 +02:00 committed by GitHub
parent f0c8b86728
commit 3e8c355ef7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View File

@ -110,7 +110,7 @@ private static bool IsAnyKataOnly(ReadOnlySpan<char> chars)
0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x00C1, // B
0x00C4, 0x00D6, 0x00DC, 0x00E4, 0x00F6, 0x00FC, 0x0020, 0x0020, 0x0020, 0x00CD, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // C
0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // D
0x0020, 0x0050, 0x004D, 0x002D, 0x0020, 0x0020, 0x003F, 0x0021, 0x002D, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0xE08E, // E
0x0020, 0x0050, 0x004D, 0x002D, 0x0020, 0x0020, 0x003F, 0x0021, 0x002E, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0xE08E, // E
0x0020, 0x0078, 0x002E, 0x002F, 0x002C, 0xE08F, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // F
];

View File

@ -84,6 +84,19 @@ public static void ConvertStringVC(string g12, string g7)
result.Should().Be(g7);
}
// The first dot is a different char than the second!
// Dot in g12 is a char used in gen1/2.
// Dot in g7 is a standard ASCII.
[Theory]
[InlineData("test", "test.")]
public static void ConvertStringVCDotConversion(string g12, string g7)
{
Span<byte> b12 = stackalloc byte[g12.Length];
var len = StringConverter1.SetString(b12, g12, g12.Length, false);
var result = StringConverter12Transporter.GetString(b12[..len], false);
result.Should().Be(g7);
}
[Theory]
[InlineData(Species.MrMime, "MRMIME")]
public static void ConvertStringG1(Species species, string expect)