Skip to content

Commit 3849250

Browse files
committed
locale: Use CRT locale as C++default
Use CRT locale as default for C++. logfile and stdout/in/err streams still use the default minimal 'C'.
1 parent 892cebd commit 3849250

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

frontend/OBSApp.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,11 +898,21 @@ OBSApp::OBSApp(int &argc, char **argv, profiler_name_store_t *store)
898898
if (!setlocale(LC_NUMERIC, "C"))
899899
blog(LOG_WARNING, "Failed to set LC_NUMERIC to C locale");
900900

901+
/* Copy C runtime locale for C++ */
902+
std::locale defaultLocale(setlocale(LC_ALL, nullptr));
903+
std::locale::global(defaultLocale);
904+
905+
/*
906+
system() is already the QLocale default, but just to be explicit about the intention.
907+
Unlike CRT and C++ locales above, QLocale doesn't support customization of locale categories and codepages.
908+
Ie. We can't enforce decimal point to be a dot and at the same time use user's preferred locale.
909+
*/
910+
QLocale::setDefault(QLocale::system());
911+
901912
if (!usingUTF8)
902913
blog(LOG_WARNING, "Failed to set UTF-8 codepage for locales");
903914

904-
const char *localeStr = setlocale(LC_ALL, nullptr);
905-
blog(LOG_INFO, "Set locale to: %s", localeStr);
915+
blog(LOG_INFO, "Set locale to: %s", defaultLocale.name().c_str());
906916

907917
#ifndef _WIN32
908918
/* Handle SIGINT properly */

0 commit comments

Comments
 (0)