mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 20:43:07 +00:00
Gen<=4 french nickname handling
Fix accented gen1-4 french pkm name retrieval https://projectpokemon.org/home/forums/topic/41614-bug-2-errors-with-pokemon-platinum/ Thanks Asia81!
This commit is contained in:
parent
772f7d9d87
commit
fd8143cae4
2 changed files with 25 additions and 0 deletions
|
@ -217,7 +217,11 @@ namespace PKHeX.Core
|
||||||
string nick = GetSpeciesName(species, lang);
|
string nick = GetSpeciesName(species, lang);
|
||||||
|
|
||||||
if (generation < 5 && (generation != 4 || species != 0)) // All caps GenIV and previous, except GenIV eggs.
|
if (generation < 5 && (generation != 4 || species != 0)) // All caps GenIV and previous, except GenIV eggs.
|
||||||
|
{
|
||||||
nick = nick.ToUpper();
|
nick = nick.ToUpper();
|
||||||
|
if (lang == 3)
|
||||||
|
nick = StringConverter.StripDiacriticsFR4(nick); // strips accents on E and I
|
||||||
|
}
|
||||||
if (generation < 3)
|
if (generation < 3)
|
||||||
nick = nick.Replace(" ", "");
|
nick = nick.Replace(" ", "");
|
||||||
return nick;
|
return nick;
|
||||||
|
|
|
@ -1963,5 +1963,26 @@ namespace PKHeX.Core
|
||||||
int index = input.IndexOf((char)0xFFFF);
|
int index = input.IndexOf((char)0xFFFF);
|
||||||
return index < 0 ? input : input.Substring(0, index);
|
return index < 0 ? input : input.Substring(0, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Strips diacritics on gen1-4 french pkm names
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">String to clean</param>
|
||||||
|
/// <returns>Cleaned string</returns>
|
||||||
|
/// <remarks>Only 4 characters are accented in gen1-4</remarks>
|
||||||
|
public static string StripDiacriticsFR4(string input)
|
||||||
|
{
|
||||||
|
var result = new StringBuilder(input.Length);
|
||||||
|
foreach (var c in input)
|
||||||
|
result.Append(FrDiacritic.TryGetValue(c, out char o) ? o : c);
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
private static readonly Dictionary<char, char> FrDiacritic = new Dictionary<char, char>
|
||||||
|
{
|
||||||
|
{ 'È', 'E' },
|
||||||
|
{ 'É', 'E' },
|
||||||
|
{ 'Ê', 'E' },
|
||||||
|
{ 'Ï', 'I' },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue