Use C++ classic locale for uses outside of Qt

This commit is contained in:
Bill Somerville 2021-03-28 23:29:57 +01:00
parent 4aff78d1c1
commit fdd69583ab
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
4 changed files with 14 additions and 22 deletions

View File

@ -3,8 +3,7 @@
#include <stdexcept>
#include <string>
#include <memory>
#include <locale.h>
#include <locale>
#include <QCoreApplication>
#include <QTextStream>
@ -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");

View File

@ -31,7 +31,7 @@
// menu that allows each dock window to be hidden or revealed.
//
#include <clocale>
#include <locale>
#include <iostream>
#include <exception>
@ -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");

View File

@ -17,6 +17,7 @@
#include <iostream>
#include <exception>
#include <locale>
#include <cstdlib>
#include <QCoreApplication>
@ -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");

View File

@ -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");