From fdd69583ab66f05f4d88f13c311593fd509afd14 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 28 Mar 2021 23:29:57 +0100 Subject: [PATCH] Use C++ classic locale for uses outside of Qt --- Audio/tools/record_time_signal.cpp | 11 ++++------- UDPExamples/MessageAggregator.cpp | 9 ++++----- UDPExamples/UDPDaemon.cpp | 8 ++++---- main.cpp | 8 ++------ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Audio/tools/record_time_signal.cpp b/Audio/tools/record_time_signal.cpp index a54c78c65..985fb00b4 100644 --- a/Audio/tools/record_time_signal.cpp +++ b/Audio/tools/record_time_signal.cpp @@ -3,8 +3,7 @@ #include #include #include - -#include +#include #include #include @@ -239,11 +238,9 @@ int main(int argc, char *argv[]) QCoreApplication app {argc, argv}; try { - ::setlocale (LC_NUMERIC, "C"); // ensure number forms are in - // consistent format, do this - // after instantiating - // QApplication so that Qt has - // correct l18n + // ensure number forms are in consistent format, do this after + // instantiating QApplication so that Qt has correct l18n + std::locale::global (std::locale::classic ()); // Override programs executable basename as application name. app.setApplicationName ("WSJT-X Record Time Signal"); diff --git a/UDPExamples/MessageAggregator.cpp b/UDPExamples/MessageAggregator.cpp index 52124045e..f44c036b8 100644 --- a/UDPExamples/MessageAggregator.cpp +++ b/UDPExamples/MessageAggregator.cpp @@ -31,7 +31,7 @@ // menu that allows each dock window to be hidden or revealed. // -#include +#include #include #include @@ -52,10 +52,9 @@ int main (int argc, char * argv[]) QApplication app {argc, argv}; try { - setlocale (LC_NUMERIC, "C"); // ensure number forms are in - // consistent format, do this after - // instantiating QApplication so - // that GUI has correct l18n + // ensure number forms are in consistent format, do this after + // instantiating QApplication so that GUI has correct l18n + std::locale::global (std::locale::classic ()); app.setApplicationName ("WSJT-X Reference UDP Message Aggregator Server"); app.setApplicationVersion ("1.0"); diff --git a/UDPExamples/UDPDaemon.cpp b/UDPExamples/UDPDaemon.cpp index 1d3a7abef..4dc04af86 100644 --- a/UDPExamples/UDPDaemon.cpp +++ b/UDPExamples/UDPDaemon.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -263,10 +264,9 @@ int main (int argc, char * argv[]) QCoreApplication app {argc, argv}; try { - setlocale (LC_NUMERIC, "C"); // ensure number forms are in - // consistent format, do this after - // instantiating QApplication so - // that GUI has correct l18n + // ensure number forms are in consistent format, do this after + // instantiating QApplication so that GUI has correct l18n + std::locale::global (std::locale::classic ()); app.setApplicationName ("WSJT-X UDP Message Server Daemon"); app.setApplicationVersion ("1.0"); diff --git a/main.cpp b/main.cpp index 2db250b33..e4d14b676 100644 --- a/main.cpp +++ b/main.cpp @@ -130,12 +130,8 @@ int main(int argc, char *argv[]) QLocale locale; // get the current system locale - // Set C/C++ locale used for logging etc. -#if defined (Q_OS_WIN) - std::locale::global (std::locale ("C")); -#else - std::locale::global (std::locale ("en_US.UTF-8")); -#endif + // reset the C+ & C global locales to the classic C locale + std::locale::global (std::locale::classic ()); // Override programs executable basename as application name. a.setApplicationName ("WSJT-X");