diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index 512acd4cc..6d5c219dd 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -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; diff --git a/Dalamud/Utility/CultureFixes.cs b/Dalamud/Utility/CultureFixes.cs new file mode 100644 index 000000000..0c048ed38 --- /dev/null +++ b/Dalamud/Utility/CultureFixes.cs @@ -0,0 +1,45 @@ +using System.Globalization; + +namespace Dalamud.Utility; + +/// +/// Class containing fixes for culture-specific issues. +/// +internal static class CultureFixes +{ + /// + /// Apply all fixes. + /// + 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); + } +}