From 9eab8b69dd242c9a40afa09371bcd7ebe9ab62b0 Mon Sep 17 00:00:00 2001 From: staviq Date: Thu, 19 Oct 2023 21:29:35 +0200 Subject: [PATCH] fix getwchar failing when LC_ALL undefined --- common/console.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/console.cpp b/common/console.cpp index f65cbc6ed..5c9302170 100644 --- a/common/console.cpp +++ b/common/console.cpp @@ -111,7 +111,16 @@ namespace console { } } - setlocale(LC_ALL, ""); + auto locale = setlocale(LC_ALL, ""); + auto lang = getenv("LANG"); + + if (locale == nullptr) { + if (lang != nullptr) { + setlocale(LC_ALL, lang); + } else{ + setlocale(LC_ALL, "C.UTF-8"); + } + } #endif }