mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 06:34:19 +00:00
Revise 4->5 encode table (Half-width symbols)
Manually transferred from English Pt to English B All revised indexes were the result in Black. Differences that were not incorporated: 0EE=09794 ♂, not 09325 ⑭ 0EF=09792 ♀, not 09326 ⑮ 0F2=00215 ×, not 09319 ⑧ 0F3=00247 ÷, not 09320 ⑨ Full-width and half-width symbols I think are related to full-width games, which English isn't. Probably has different handling for other language, plus it'd result in other duplicates of the half-width symbols. Revise not-found char glyph to return ? instead of {terminator}, to match the game's behavior. Again, this might be language specific, but whatever. Make the Convert char methods public, add a few unit tests. Closes #3172 Co-Authored-By: Lusamine <30205550+Lusamine@users.noreply.github.com>
This commit is contained in:
parent
665880e081
commit
390cf518b8
2 changed files with 26 additions and 13 deletions
|
@ -179,10 +179,10 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="val">Encoded value.</param>
|
||||
/// <returns>Decoded value (unicode).</returns>
|
||||
private static ushort ConvertValue2CharG4(ushort val)
|
||||
public static ushort ConvertValue2CharG4(ushort val)
|
||||
{
|
||||
return G4ValueId.TryGetValue(val, out int index)
|
||||
? G4Chars[index] : ushort.MaxValue;
|
||||
? G4Chars[index] : '?';
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -190,10 +190,10 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
/// <param name="chr">Decoded value (unicode).</param>
|
||||
/// <returns>Encoded value.</returns>
|
||||
private static ushort ConvertChar2ValueG4(ushort chr)
|
||||
public static ushort ConvertChar2ValueG4(ushort chr)
|
||||
{
|
||||
return G4CharId.TryGetValue(chr, out int index)
|
||||
? G4Values[index] : ushort.MaxValue;
|
||||
? G4Values[index] : (ushort)00428; // '?'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -243,7 +243,7 @@ namespace PKHeX.Core
|
|||
00226, 00227, 00228, 00229, 00230, 00231, 00232, 00233, 00234, 00235, 00236, 00237, 00238, 00239, 00240, 00241,
|
||||
00242, 00243, 00244, 00245, 00246, 00247, 00248, 00249, 00250, 00251, 00252, 00253, 00254, 00255, 00256, 00257,
|
||||
00258, 00259, 00260, 00261, 00262, 00263, 00264, 00265, 00266, 00267, 00268, 00269, 00270, 00271, 00272, 00273,
|
||||
00274, 00275, 00276, 00277, 00278, 00279, 00280, 00281, 00282, 00283, 00284, 00285, 00286, 00287, 00288, 00289,
|
||||
00275, 00276, 00277, 00278, 00279, 00280, 00281, 00282, 00283, 00284, 00285, 00286, 00287, 00288, 00289,
|
||||
00290, 00291, 00292, 00293, 00294, 00295, 00296, 00297, 00298, 00299, 00300, 00301, 00302, 00303, 00304, 00305,
|
||||
00306, 00307, 00308, 00309, 00310, 00311, 00312, 00313, 00314, 00315, 00316, 00317, 00318, 00319, 00320, 00321,
|
||||
00322, 00323, 00324, 00325, 00326, 00327, 00328, 00329, 00330, 00331, 00332, 00333, 00334, 00335, 00336, 00337,
|
||||
|
@ -255,8 +255,8 @@ namespace PKHeX.Core
|
|||
00418, 00419, 00420, 00421, 00422, 00423, 00424, 00425, 00426, 00427, 00428, 00429, 00430, 00431, 00432, 00433,
|
||||
00434, 00435, 00436, 00437, 00438, 00439, 00440, 00441, 00442, 00443, 00444, 00445, 00446, 00447, 00448, 00449,
|
||||
00450, 00451, 00452, 00453, 00454, 00455, 00456, 00457, 00458, 00459, 00460, 00461, 00462, 00463, 00464, 00465,
|
||||
00466, 00467, 00468, 00469, 00470, 00471, 00472, 00473, 00474, 00475, 00476, 00477, 00478, 00479, 00480, 00481,
|
||||
00488, 00489, 00490, 01025, 01026, 01027, 01028, 01029, 01030, 01031, 01032, 01033, 01034, 01035, 01036, 01037,
|
||||
00466, 00467, 00468, 00469, 00470, 00471, 00472, 00473, 00474, 00475, 00476, 00477, 00478,
|
||||
01025, 01026, 01027, 01028, 01029, 01030, 01031, 01032, 01033, 01034, 01035, 01036, 01037,
|
||||
01038, 01039, 01040, 01041, 01042, 01043, 01044, 01045, 01046, 01047, 01048, 01049, 01050, 01051, 01052, 01053,
|
||||
01054, 01055, 01056, 01057, 01058, 01059, 01060, 01061, 01062, 01063, 01064, 01065, 01066, 01067, 01068, 01069,
|
||||
01070, 01071, 01072, 01073, 01074, 01075, 01076, 01077, 01078, 01079, 01080, 01081, 01082, 01083, 01084, 01085,
|
||||
|
@ -428,9 +428,9 @@ namespace PKHeX.Core
|
|||
65334, 65335, 65336, 65337, 65338, 65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355,
|
||||
65356, 65357, 65358, 65359, 65360, 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370, 65281,
|
||||
65311, 12289, 12290, 08943, 12539, 65295, 12300, 12301, 12302, 12303, 65288, 65289, 09325, 09326, 65291, 12540,
|
||||
09319, 09320, 65309, 65370, 65306, 65307, 65294, 65292, 09327, 09328, 09329, 09330, 09331, 09332, 09333, 09334,
|
||||
09335, 09336, 65312, 09337, 65285, 09338, 09339, 09341, 10052, 09739, 09812, 09813, 09738, 08663, 08664, 09790,
|
||||
00165, 09800, 09801, 09802, 09803, 09804, 09805, 09806, 09807, 08592, 08593, 08595, 08594, 08227, 65286, 00048,
|
||||
09319, 09320, 65309, 65374, 65306, 65307, 65294, 65292, 09824, 09827, 09829, 09830, 09733, 09678, 09675, 09633,
|
||||
09651, 09671, 65312, 09834, 65285, 09728, 09729, 09730, 09731, 09312, 09313, 09314, 09738, 09316, 09317, 09318,
|
||||
09800, 09801, 09802, 09803, 09804, 09805, 09806, 09807, 08592, 08593, 08595, 08594, 08227, 65286, 00048,
|
||||
00049, 00050, 00051, 00052, 00053, 00054, 00055, 00056, 00057, 00065, 00066, 00067, 00068, 00069, 00070, 00071,
|
||||
00072, 00073, 00074, 00075, 00076, 00077, 00078, 00079, 00080, 00081, 00082, 00083, 00084, 00085, 00086, 00087,
|
||||
00088, 00089, 00090, 00097, 00098, 00099, 00100, 00101, 00102, 00103, 00104, 00105, 00106, 00107, 00108, 00109,
|
||||
|
@ -442,8 +442,8 @@ namespace PKHeX.Core
|
|||
00351, 00170, 00186, 00185, 00178, 00179, 00036, 00161, 00191, 00033, 00063, 00044, 00046, 09324, 65381, 00047,
|
||||
08216, 08217, 08220, 08221, 08222, 12298, 12299, 00040, 00041, 09794, 09792, 00043, 00045, 00042, 00035, 00061,
|
||||
00038, 00126, 00058, 00059, 09327, 09328, 09329, 09330, 09331, 09332, 09333, 09334, 09335, 09336, 00064, 09337,
|
||||
00037, 09338, 09339, 09340, 09341, 09342, 09343, 09344, 09345, 09346, 09347, 09348, 00032, 09349, 09350, 09351,
|
||||
00176, 00095, 65343, 44032, 44033, 44036, 44039, 44040, 44041, 44042, 44048, 44049, 44050, 44051, 44052, 44053,
|
||||
00037, 09338, 09339, 09340, 09341, 09342, 09343, 09344, 09345, 09346, 09347, 09348, 00032,
|
||||
44032, 44033, 44036, 44039, 44040, 44041, 44042, 44048, 44049, 44050, 44051, 44052, 44053,
|
||||
44054, 44055, 44057, 44058, 44059, 44060, 44061, 44064, 44068, 44076, 44077, 44079, 44080, 44081, 44088, 44089,
|
||||
44092, 44096, 44107, 44109, 44116, 44120, 44124, 44144, 44145, 44148, 44151, 44152, 44154, 44160, 44161, 44163,
|
||||
44164, 44165, 44166, 44169, 44170, 44171, 44172, 44176, 44180, 44188, 44189, 44191, 44192, 44193, 44200, 44201,
|
||||
|
@ -601,7 +601,6 @@ namespace PKHeX.Core
|
|||
|
||||
private static readonly Dictionary<ushort, int> G4CharId = G4Chars
|
||||
.Select((value, index) => new KeyValuePair<ushort, int>(value, index))
|
||||
.GroupBy(z => z.Key).Select(z => z.First()) // 65370 & 9327-9341 are in there twice?
|
||||
.ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -58,5 +58,19 @@ namespace PKHeX.Tests.PKM
|
|||
indata.SequenceEqual(outdata).Should()
|
||||
.BeTrue($"expected {check} to set properly, instead got {string.Join(", ", outdata.Select(z => $"{z:X2}"))}");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0x0F5, 0xFF5E)] // ~
|
||||
[InlineData(0x0FA, 0x2660)] // ♠
|
||||
[InlineData(0x0FB, 0x2663)] // ♣
|
||||
[InlineData(0x0FC, 0x2665)] // ♥
|
||||
[InlineData(0x0FD, 0x2666)] // ♦
|
||||
[InlineData(0x0FE, 0x2605)] // ★
|
||||
[InlineData(0x105, 0x266A)] // ♪
|
||||
public static void Encode45(ushort g4, char g5)
|
||||
{
|
||||
StringConverter4.ConvertChar2ValueG4(g5).Should().Be(g4);
|
||||
StringConverter4.ConvertValue2CharG4(g4).Should().Be(g5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue