diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index f954e8b25d..b3e147c0ba 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -7487,7 +7487,22 @@ double QString::toDouble(bool *ok) const double QStringView::toDouble(bool *ok) const { - return QLocaleData::c()->stringToDouble(*this, ok, QLocale::RejectGroupSeparator); + QStringView string = qt_trimmed(*this); + QVarLengthArray latin1(string.size()); + qt_to_latin1(latin1.data(), string.utf16(), string.size()); + + // We need lowetcased "inf" and "nan". + // This mangles the string, but nothing can become a number or letter + // that isn't already a number or letter. + for (uchar &c : latin1) { + if (c >= 'A') + c |= 0x20; + } + + auto r = qt_asciiToDouble(reinterpret_cast(latin1.data()), string.size()); + if (ok != nullptr) + *ok = r.ok(); + return r.result; } /*!