mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-06-01 04:53:29 -05:00
match á and é
This commit is contained in:
parent
280fae25a6
commit
a70cdd38af
|
|
@ -117,15 +117,16 @@ namespace HavenSoft.HexManiac.Core {
|
|||
/// Returns how many letters within partial can be matched into the full string
|
||||
/// </summary>
|
||||
public static int MatchLength(this string full, string partial, bool onlyCheckLettersAndDigits = false) {
|
||||
full = full.Replace("é", "e");
|
||||
int j = 0;
|
||||
for (int i = 0; i < partial.Length; i++) {
|
||||
if (onlyCheckLettersAndDigits && !char.IsLetterOrDigit(partial[i])) continue;
|
||||
var testPartial = char.ToUpperInvariant(partial[i]);
|
||||
if (partial[i] == 'é') testPartial = 'E';
|
||||
if (partial[i] == 'á') testPartial = 'A';
|
||||
while (j < full.Length) {
|
||||
var testFull = char.ToUpperInvariant(full[j]);
|
||||
if (full[j] == 'é') testFull = 'E';
|
||||
if (full[j] == 'á') testFull = 'A';
|
||||
j++;
|
||||
if (testFull == testPartial) break;
|
||||
if (j == full.Length) return i;
|
||||
|
|
|
|||
|
|
@ -703,6 +703,12 @@ namespace HavenSoft.HexManiac.Tests {
|
|||
Assert.Equal(bytes, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SpecialCharacters_MatchAgainstNormalCharacters_Match() {
|
||||
Assert.True("á.é".MatchesPartialWithReordering("ea"));
|
||||
Assert.True("a.e".MatchesPartialWithReordering("éá"));
|
||||
}
|
||||
|
||||
private void HackTextConverter(string game) {
|
||||
var converter = new PCSConverter(game);
|
||||
var property = Model.GetType().GetProperty(nameof(Model.TextConverter));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user