From d41aac175ffdf695a051e2b27ad74153dbee3799 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sun, 14 Jun 2026 15:02:00 -0500 Subject: [PATCH] Allow !? for jpn gen2 strings Closes #4821 not sure this is a perfect solution (traded from gen1=>nicknamed complainers, or iterator prefer-matching gen1 when having !?) --- PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs | 2 +- .../Legality/Verifiers/TrainerNameVerifier.cs | 2 +- PKHeX.Core/PKM/Strings/StringConverter2.cs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs index 2457969d7..3e92928dd 100644 --- a/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/NicknameVerifier.cs @@ -370,7 +370,7 @@ private void VerifyG1NicknameWithinBounds(LegalityAnalysis data, ReadOnlySpan 10) data.AddLine(GetInvalid(NickLengthLong, 10)); } - else if (StringConverter1.GetIsJapanese(str)) + else if (data.EncounterOriginal.Generation == 1 ? StringConverter1.GetIsJapanese(str) : StringConverter2.GetIsJapanese(str)) { if (str.Length > 5) data.AddLine(GetInvalid(NickLengthLong, 5)); diff --git a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs index d01180bc0..16c1af44e 100644 --- a/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs +++ b/PKHeX.Core/Legality/Verifiers/TrainerNameVerifier.cs @@ -146,7 +146,7 @@ private void VerifyGBOTWithinBounds(LegalityAnalysis data, ReadOnlySpan st { if (str.Length > 5) data.AddLine(GetInvalid(OTLong, 5)); - if (!StringConverter1.GetIsJapanese(str)) + if (data.EncounterOriginal.Generation == 1 ? !StringConverter1.GetIsJapanese(str) : !StringConverter2.GetIsJapanese(str)) data.AddLine(GetInvalid(G1CharOT)); } else if (pk.Korean) diff --git a/PKHeX.Core/PKM/Strings/StringConverter2.cs b/PKHeX.Core/PKM/Strings/StringConverter2.cs index 067e23989..84174feba 100644 --- a/PKHeX.Core/PKM/Strings/StringConverter2.cs +++ b/PKHeX.Core/PKM/Strings/StringConverter2.cs @@ -18,7 +18,20 @@ public static class StringConverter2 public const char TradeOT = StringConverter1.TradeOT; public const char LineBreak = '⏎'; // Mail - public static bool GetIsJapanese(ReadOnlySpan str) => StringConverter1.GetIsJapanese(str); + /// + /// Quick check if the input string is entirely Japanese characters. + /// + /// . This also adds ? and !. + public static bool GetIsJapanese(ReadOnlySpan str) + { + foreach (var x in str) + { + if (!IsJapanese(x)) + return false; + } + return true; + static bool IsJapanese(char c) => c is (>= '\u3000' and <= '\u30FC') or ('?' or '!'); + } public static bool GetIsEnglish(ReadOnlySpan str) => !GetIsJapanese(str); public static bool GetIsJapanese(ReadOnlySpan raw) => AllCharsInTable(raw, TableJP);