mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
patch NNBSP number separator out of cultures that use it (fixes #2157)
This commit is contained in:
parent
1d9116f0a0
commit
ce5ee71c91
2 changed files with 48 additions and 0 deletions
|
|
@ -178,6 +178,9 @@ public sealed class EntryPoint
|
|||
throw new Exception("Working directory was invalid");
|
||||
|
||||
Reloaded.Hooks.Tools.Utilities.FasmBasePath = new DirectoryInfo(info.WorkingDirectory);
|
||||
|
||||
// Apply common fixes for culture issues
|
||||
CultureFixes.Apply();
|
||||
|
||||
// This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls;
|
||||
|
|
|
|||
45
Dalamud/Utility/CultureFixes.cs
Normal file
45
Dalamud/Utility/CultureFixes.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.Globalization;
|
||||
|
||||
namespace Dalamud.Utility;
|
||||
|
||||
/// <summary>
|
||||
/// Class containing fixes for culture-specific issues.
|
||||
/// </summary>
|
||||
internal static class CultureFixes
|
||||
{
|
||||
/// <summary>
|
||||
/// Apply all fixes.
|
||||
/// </summary>
|
||||
public static void Apply()
|
||||
{
|
||||
PatchNumberSeparator();
|
||||
}
|
||||
|
||||
private static void PatchNumberSeparator()
|
||||
{
|
||||
// Reset formatting specifier for the "digit grouping symbol" to an empty string
|
||||
// for cultures that use a narrow no-break space (U+202F).
|
||||
// This glyph is not present in any game fonts and not in the range for our Noto
|
||||
// so it will be rendered as a geta (=) instead. That's a hack, but it works and
|
||||
// doesn't look as weird.
|
||||
void PatchCulture(CultureInfo info)
|
||||
{
|
||||
const string invalidGroupSeparator = "\u202F";
|
||||
const string replacedGroupSeparator = " ";
|
||||
if (info.NumberFormat.NumberGroupSeparator == invalidGroupSeparator)
|
||||
info.NumberFormat.NumberGroupSeparator = replacedGroupSeparator;
|
||||
|
||||
if (info.NumberFormat.NumberDecimalSeparator == invalidGroupSeparator)
|
||||
info.NumberFormat.NumberDecimalSeparator = replacedGroupSeparator;
|
||||
|
||||
if (info.NumberFormat.CurrencyGroupSeparator == invalidGroupSeparator)
|
||||
info.NumberFormat.CurrencyGroupSeparator = replacedGroupSeparator;
|
||||
|
||||
if (info.NumberFormat.CurrencyDecimalSeparator == invalidGroupSeparator)
|
||||
info.NumberFormat.CurrencyDecimalSeparator = replacedGroupSeparator;
|
||||
}
|
||||
|
||||
PatchCulture(CultureInfo.CurrentCulture);
|
||||
PatchCulture(CultureInfo.CurrentUICulture);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue