From 87d6844bb00977089cd14d53dc8156a32de65eb7 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Sun, 26 Apr 2026 13:52:01 -0500 Subject: Fix: fall back to "C" locale when system lacks user's LANG std::locale("") at static-init throws std::runtime_error on systems where the requested locale (e.g. en_US.UTF-8) isn't generated, killing Fluorine before main() runs. Wrap in try/catch and fall back to the classic locale. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/src/shared/util.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/src/shared/util.cpp b/src/src/shared/util.cpp index ec720d2..71e735e 100644 --- a/src/src/shared/util.cpp +++ b/src/src/shared/util.cpp @@ -129,7 +129,19 @@ std::wstring ToWString(const std::string& source, bool utf8) } #endif -static std::locale loc(""); +static std::locale makeUserLocale() +{ + // std::locale("") reads LANG/LC_* env vars. If user's system lacks the + // requested locale (e.g. en_US.UTF-8 not generated), constructor throws + // runtime_error. Fall back to "C" so startup doesn't abort. + try { + return std::locale(""); + } catch (const std::runtime_error&) { + return std::locale::classic(); + } +} + +static std::locale loc = makeUserLocale(); static auto locToLowerW = [](wchar_t in) -> wchar_t { return std::tolower(in, loc); }; -- cgit v1.3.1