Release 1.10.7.2 - Autumn Update 2025 Hotfix 4

This commit is contained in:
Regalis11
2025-10-22 14:54:03 +03:00
parent 37ffc94551
commit 7e25111487
17 changed files with 315 additions and 83 deletions
@@ -1874,5 +1874,24 @@ namespace Barotrauma
}
return true;
}
/// <summary>
/// Normalizes a string by replacing all homoglyph characters with their ASCII equivalents.
/// This allows for efficient homoglyph-aware string comparisons using standard string operations.
/// </summary>
public static string Normalize(string input)
{
if (string.IsNullOrEmpty(input)) { return input; }
var normalized = new char[input.Length];
for (int i = 0; i < input.Length; i++)
{
uint charCode = (uint)input[i];
uint[] glyphGroup = homoglyphs.Find(g => g.Contains(charCode));
// The first element in each homoglyph group is the canonical ASCII character
normalized[i] = glyphGroup != null ? (char)glyphGroup[0] : input[i];
}
return new string(normalized);
}
}
}