summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 656640755..0de3e6002 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -829,10 +829,16 @@ int parsePressureToMbar(const QString &text)
{
int mbar;
QString numOnly = text;
- numOnly.replace(",", ".").remove(QRegExp("[^0-9.]"));
+ // different locales use different symbols as group separator or decimal separator
+ // (I think it's usually '.' and ',' - but maybe there are others?)
+ // let's use Qt's help to get the parsing right
+ QString validNumberCharacters("0-9");
+ validNumberCharacters += loc.decimalPoint();
+ validNumberCharacters += loc.groupSeparator();
+ numOnly.remove(QRegExp(QString("[^%1]").arg(validNumberCharacters)));
if (numOnly.isEmpty())
return 0;
- double number = numOnly.toDouble();
+ double number = loc.toDouble(numOnly);
if (text.contains(gettextFromC::tr("bar"), Qt::CaseInsensitive)) {
mbar = lrint(number * 1000);
} else if (text.contains(gettextFromC::tr("psi"), Qt::CaseInsensitive)) {