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:
Kurt 2017-09-19 21:27:01 -07:00
parent 772f7d9d87
commit fd8143cae4
2 changed files with 25 additions and 0 deletions

View file

@ -217,7 +217,11 @@ namespace PKHeX.Core
string nick = GetSpeciesName(species, lang);
if (generation < 5 && (generation != 4 || species != 0)) // All caps GenIV and previous, except GenIV eggs.
{
nick = nick.ToUpper();
if (lang == 3)
nick = StringConverter.StripDiacriticsFR4(nick); // strips accents on E and I
}
if (generation < 3)
nick = nick.Replace(" ", "");
return nick;

View file

@ -1963,5 +1963,26 @@ namespace PKHeX.Core
int index = input.IndexOf((char)0xFFFF);
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' },
};
}
}