From 49488bb5039d95a75f23df935ec7af7e59fd7387 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 24 Jun 2021 09:16:36 -0700 Subject: [PATCH] Use invariant culture for ToUpper/ToLower Turkish is quite the language; let's try to prevent any errors down the road for internal/game string case changes. --- PKHeX.Core/Legality/Restrictions/WordFilter.cs | 2 +- PKHeX.Core/MysteryGifts/MysteryGift.cs | 2 +- PKHeX.Core/PKM/PKM.cs | 2 +- PKHeX.Core/PKM/Util/SpeciesName.cs | 4 ++-- PKHeX.Core/Saves/Util/SaveExtensions.cs | 2 +- PKHeX.Drawing/Sprites/SpriteUtil.cs | 6 +++--- PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs | 2 +- PKHeX.WinForms/Util/WinFormsUtil.cs | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/PKHeX.Core/Legality/Restrictions/WordFilter.cs b/PKHeX.Core/Legality/Restrictions/WordFilter.cs index 3428b82c6..1c6088ccd 100644 --- a/PKHeX.Core/Legality/Restrictions/WordFilter.cs +++ b/PKHeX.Core/Legality/Restrictions/WordFilter.cs @@ -46,7 +46,7 @@ namespace PKHeX.Core return false; } - var msg = message.ToLower(); + var msg = message.ToLowerInvariant(); // Check dictionary lock (dictLock) { diff --git a/PKHeX.Core/MysteryGifts/MysteryGift.cs b/PKHeX.Core/MysteryGifts/MysteryGift.cs index e1249ec5e..263eed7ef 100644 --- a/PKHeX.Core/MysteryGifts/MysteryGift.cs +++ b/PKHeX.Core/MysteryGifts/MysteryGift.cs @@ -62,7 +62,7 @@ namespace PKHeX.Core _ => null }; - public string Extension => GetType().Name.ToLower(); + public string Extension => GetType().Name.ToLowerInvariant(); public string FileName => $"{CardHeader}.{Extension}"; public abstract int Generation { get; } diff --git a/PKHeX.Core/PKM/PKM.cs b/PKHeX.Core/PKM/PKM.cs index 9dca07002..faa97a1d7 100644 --- a/PKHeX.Core/PKM/PKM.cs +++ b/PKHeX.Core/PKM/PKM.cs @@ -13,7 +13,7 @@ namespace PKHeX.Core public static readonly string[] Extensions = PKX.GetPKMExtensions(); public abstract int SIZE_PARTY { get; } public abstract int SIZE_STORED { get; } - public string Extension => GetType().Name.ToLower(); + public string Extension => GetType().Name.ToLowerInvariant(); public abstract PersonalInfo PersonalInfo { get; } public virtual IReadOnlyList ExtraBytes => Array.Empty(); diff --git a/PKHeX.Core/PKM/Util/SpeciesName.cs b/PKHeX.Core/PKM/Util/SpeciesName.cs index 9dc146efe..406adc625 100644 --- a/PKHeX.Core/PKM/Util/SpeciesName.cs +++ b/PKHeX.Core/PKM/Util/SpeciesName.cs @@ -107,7 +107,7 @@ namespace PKHeX.Core // All names are uppercase. var sb = new System.Text.StringBuilder(nick); for (int i = 0; i < sb.Length; i++) - sb[i] = char.ToUpper(sb[i]); + sb[i] = char.ToUpperInvariant(sb[i]); if (language == (int)LanguageID.French) StringConverter4.StripDiacriticsFR4(sb); // strips accents on E and I @@ -134,7 +134,7 @@ namespace PKHeX.Core return nick; // Gen2: All Caps - return nick.ToUpper(); + return nick.ToUpperInvariant(); } /// diff --git a/PKHeX.Core/Saves/Util/SaveExtensions.cs b/PKHeX.Core/Saves/Util/SaveExtensions.cs index 57daf69c4..da49de1f2 100644 --- a/PKHeX.Core/Saves/Util/SaveExtensions.cs +++ b/PKHeX.Core/Saves/Util/SaveExtensions.cs @@ -172,7 +172,7 @@ namespace PKHeX.Core return LoadTemplateInternal(sav); var di = new DirectoryInfo(templatePath); - string path = Path.Combine(templatePath, $"{di.Name}.{sav.PKMType.Name.ToLower()}"); + string path = Path.Combine(templatePath, $"{di.Name}.{sav.PKMType.Name.ToLowerInvariant()}"); if (!File.Exists(path) || !PKX.IsPKM(new FileInfo(path).Length)) return LoadTemplateInternal(sav); diff --git a/PKHeX.Drawing/Sprites/SpriteUtil.cs b/PKHeX.Drawing/Sprites/SpriteUtil.cs index bf0d1d2bd..9d615c6b5 100644 --- a/PKHeX.Drawing/Sprites/SpriteUtil.cs +++ b/PKHeX.Drawing/Sprites/SpriteUtil.cs @@ -23,7 +23,7 @@ namespace PKHeX.Drawing public static Image? GetRibbonSprite(string name) { - var resource = name.Replace("CountG3", "G3").ToLower(); + var resource = name.Replace("CountG3", "G3").ToLowerInvariant(); return (Bitmap?)Resources.ResourceManager.GetObject(resource); } @@ -37,14 +37,14 @@ namespace PKHeX.Drawing { if (max != 4) // Memory { - var sprite = name.ToLower(); + var sprite = name.ToLowerInvariant(); if (max == value) return sprite + "2"; return sprite; } // Count ribbons - string n = name.Replace("Count", string.Empty).ToLower(); + string n = name.Replace("Count", string.Empty).ToLowerInvariant(); return value switch { 2 => n + "super", diff --git a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs index 6e0d43ad9..5681424ec 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs @@ -27,7 +27,7 @@ namespace PKHeX.WinForms CB_Format.Items.Clear(); CB_Format.Items.Add(MsgAny); foreach (Type t in BatchEditing.Types) - CB_Format.Items.Add(t.Name.ToLower()); + CB_Format.Items.Add(t.Name.ToLowerInvariant()); CB_Format.Items.Add(MsgAll); CB_Format.SelectedIndex = CB_Require.SelectedIndex = 0; diff --git a/PKHeX.WinForms/Util/WinFormsUtil.cs b/PKHeX.WinForms/Util/WinFormsUtil.cs index a02f81ef4..b49ffb305 100644 --- a/PKHeX.WinForms/Util/WinFormsUtil.cs +++ b/PKHeX.WinForms/Util/WinFormsUtil.cs @@ -375,7 +375,7 @@ namespace PKHeX.WinForms private static void ExportSAV(SaveFile sav, string path) { - var ext = Path.GetExtension(path).ToLower(); + var ext = Path.GetExtension(path).ToLowerInvariant(); var flags = sav.Metadata.GetSuggestedFlags(ext); try