diff --git a/src/C4Language.cpp b/src/C4Language.cpp index a6340a99..661942c3 100644 --- a/src/C4Language.cpp +++ b/src/C4Language.cpp @@ -429,6 +429,10 @@ bool C4Language::LoadStringTable(C4Group &hGroup, const char *strCode) // Set the internal charset SCopy(LoadResStr(C4ResStrTableKey::IDS_LANG_CHARSET), Config.General.LanguageCharset); +#ifdef _WIN32 + Application.LogSystem.SetConsoleCharset(C4Config::GetCharsetCodePage(Config.General.LanguageCharset)); +#endif + #ifdef HAVE_ICONV_AND_LANGINFO_H const char *const to_set = nl_langinfo(CODESET); if (local_to_host == iconv_t(-1)) diff --git a/src/C4Log.cpp b/src/C4Log.cpp index 19c05344..d528d93d 100644 --- a/src/C4Log.cpp +++ b/src/C4Log.cpp @@ -382,6 +382,17 @@ void C4LogSystem::ClearRingbuffer() ringbufferSink->Clear(); } +#ifdef _WIN32 + +void C4LogSystem::SetConsoleCharset(const std::int32_t charset) +{ + SetConsoleCP(charset); + SetConsoleOutputCP(charset); +} + +#endif + + void LogNTr(const spdlog::level::level_enum level, const std::string_view message) { Application.LogSystem.GetLogger()->log(level, message); diff --git a/src/C4Log.h b/src/C4Log.h index fd9fb8f3..88e02417 100644 --- a/src/C4Log.h +++ b/src/C4Log.h @@ -126,6 +126,10 @@ class C4LogSystem void EnableDebugLog(bool enable); void SetVerbose(bool verbose); +#ifdef _WIN32 + void SetConsoleCharset(std::int32_t charset); +#endif + private: std::shared_ptr logger; std::shared_ptr loggerSilent;