/// <summary> /// Gets the bytes for a Generation specific string according to the input parameters. /// </summary> /// <param name="value">Decoded string.</param> /// <param name="generation">Generation string format</param> /// <param name="jp">Encoding is Japanese</param> /// <param name="isBigEndian">Encoding is Big Endian</param> /// <param name="maxLength"></param> /// <param name="language"></param> /// <param name="padTo">Pad to given length</param> /// <param name="padWith">Pad with value</param> /// <returns>Encoded data.</returns> public static byte[] SetString(string value, int generation, bool jp, bool isBigEndian, int maxLength, int language = 0, int padTo = 0, ushort padWith = 0) { if (isBigEndian) { return(generation == 3 ? StringConverter3.SetBEString3(value, maxLength, padTo, padWith) : StringConverter4.SetBEString4(value, maxLength, padTo, padWith)); } switch (generation) { case 1: case 2: return(StringConverter12.SetString1(value, maxLength, jp, padTo, padWith)); case 3: return(StringConverter3.SetString3(value, maxLength, jp, padTo, padWith)); case 4: return(StringConverter4.SetString4(value, maxLength, padTo, padWith)); case 5: return(SetString5(value, maxLength, padTo, padWith)); case 6: return(SetString6(value, maxLength, padTo, padWith)); default: return(SetString7(value, maxLength, language, padTo, padWith)); } }
private string GetString(int Offset, int Count) => StringConverter4.GetString4(Data, Offset, Count);
/// <summary> /// Converts bytes to a string according to the input parameters. /// </summary> /// <param name="data">Encoded data</param> /// <param name="generation">Generation string format</param> /// <param name="jp">Encoding is Japanese</param> /// <param name="isBigEndian">Encoding is Big Endian</param> /// <param name="count">Length of data to read.</param> /// <param name="offset">Offset to read from</param> /// <returns>Decoded string.</returns> public static string GetString(byte[] data, int generation, bool jp, bool isBigEndian, int count, int offset = 0) { if (isBigEndian) { return(generation == 3 ? StringConverter3.GetBEString3(data, offset, count) : StringConverter4.GetBEString4(data, offset, count)); } return(generation switch { 1 or 2 => StringConverter12.GetString1(data, offset, count, jp), 3 => StringConverter3.GetString3(data, offset, count, jp), 4 => StringConverter4.GetString4(data, offset, count), 5 => GetString5(data, offset, count), 6 => GetString6(data, offset, count), _ => GetString7(data, offset, count), });
/// <summary> /// Converts bytes to a string according to the input parameters. /// </summary> /// <param name="data">Encoded data</param> /// <param name="generation">Generation string format</param> /// <param name="jp">Encoding is Japanese</param> /// <param name="isBigEndian">Encoding is Big Endian</param> /// <param name="count">Length of data to read.</param> /// <param name="offset">Offset to read from</param> /// <returns>Decoded string.</returns> public static string GetString(byte[] data, int generation, bool jp, bool isBigEndian, int count, int offset = 0) { if (isBigEndian) { return(generation == 3 ? StringConverter3.GetBEString3(data, offset, count) : StringConverter4.GetBEString4(data, offset, count)); } switch (generation) { case 1: case 2: return(StringConverter12.GetString1(data, offset, count, jp)); case 3: return(StringConverter3.GetString3(data, offset, count, jp)); case 4: return(StringConverter4.GetString4(data, offset, count)); case 5: return(GetString5(data, offset, count)); case 6: return(GetString6(data, offset, count)); default: return(GetString7(data, offset, count)); } }
private byte[] SetString(string value, int maxLength) => StringConverter4.SetString4(value, maxLength);
public string GetString(int Offset, int Count) => StringConverter4.GetBEString4(Data, Offset, Count);
public byte[] SetString(string value, int maxLength) => StringConverter4.SetBEString4(value, maxLength);
public override string GetString(byte[] data, int offset, int length) => StringConverter4.GetBEString4(data, offset, length);
/// <summary> /// Gets a Pokémon's default name for the desired language ID and generation. /// </summary> /// <param name="species">National Dex number of the Pokémon. Should be 0 if an egg.</param> /// <param name="language">Language ID of the Pokémon</param> /// <param name="generation">Generation specific formatting option</param> /// <returns>Generation specific default species name</returns> public static string GetSpeciesNameGeneration(int species, int language, int generation) { if (generation >= 5) { // Species Names for Chinese (Simplified) were revised during Generation 8 Crown Tundra DLC (#2). // For a Gen7 species name request, return the old species name (hardcoded... yay). // In an updated Gen8 game, the species nickname will automatically reset to the correct localization (on save/load ?), fixing existing entries. // We don't differentiate patch revisions, just generation; Gen8 will return the latest localization. // Gen8 did revise CHT species names, but only for Barraskewda, Urshifu, and Zarude. These species are new (Gen8); we can just use the latest. if (generation == 7 && language == (int)LanguageID.ChineseS) { switch (species) { // Revised in DLC1 - Isle of Armor // https://cn.portal-pokemon.com/topics/event/200323190120_post_19.html case (int)Species.Porygon2: return("多边兽Ⅱ"); // Later changed to 多边兽2型 case (int)Species.PorygonZ: return("多边兽Z"); // Later changed to 多边兽乙型 case (int)Species.Mimikyu: return("谜拟Q"); // Later changed to 谜拟丘 // Revised in DLC2 - Crown Tundra // https://cn.portal-pokemon.com/topics/event/201020170000_post_21.html case (int)Species.Cofagrigus: return("死神棺"); // Later changed to 迭失棺 case (int)Species.Pangoro: return("流氓熊猫"); // Later changed to 霸道熊猫 case (int)Species.Nickit: return("偷儿狐"); // Later changed to 狡小狐 case (int)Species.Thievul: return("狐大盗"); // Later changed to 猾大狐 case (int)Species.Toxel: return("毒电婴"); // Later changed to 电音婴 case (int)Species.Runerigus: return("死神板"); // Later changed to 迭失板 } } return(GetSpeciesName(species, language)); } if (species == 0) { if (generation == 3) { return("タマゴ"); // All Gen3 eggs are treated as JPN eggs. } if (language == (int)LanguageID.French) { return("Oeuf"); // Gen2 & Gen4 don't use Œuf like in future games } } string nick = GetSpeciesName(species, language); if (generation == 2 && language == (int)LanguageID.Korean) { return(StringConverter2KOR.LocalizeKOR2(nick)); } if (generation != 4 || species != 0) // All caps GenIV and previous, except GenIV eggs. { nick = nick.ToUpper(); if (language == (int)LanguageID.French) { nick = StringConverter4.StripDiacriticsFR4(nick); // strips accents on E and I } } if (generation < 3) { nick = nick.Replace(" ", string.Empty); } return(nick); }