summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-05-09 11:57:12 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2023-05-15 14:02:47 +0200
commit4768fcf836f1eb0f59ab62a29eb821b433a239c1 (patch)
tree6732b7b9568fc9237f063e1fbaf8763016d2e222
parent637e1542cfd75969edabba547af693f29411e6aa (diff)
downloadqtbase-4768fcf836f1eb0f59ab62a29eb821b433a239c1.tar.gz
Fix case-sensitivity of exponent separator check in Cyrillic fall-back
When matching the locale's correct exponent separator, QLocale was doing a case-insensitive match; but the Cyrillic fall-back was matching case-sensitively, so failed to catch the case of lower-case e and its Cyrillic equivalent, when used in a Cyrillic font in place of the upper-case form of the other, where that's the locale's official separator. So make this comparison case-insensitive. Added some test-cases for the lower-case exponential separator. Pick-to: 6.5 Fixes: QTBUG-113443 Change-Id: I18e22d7b3451fbb61e87d5b93661eadff3c7356e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
-rw-r--r--src/corelib/text/qlocale.cpp3
-rw-r--r--tests/auto/corelib/text/qlocale/tst_qlocale.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 9467f7795c..71027b697b 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -4065,7 +4065,8 @@ char NumericTokenizer::nextToken()
// writing Cyrillic may well use that; and Ukrainians might well use E.
// All other Cyrillic locales (officially) use plain ASCII E.
if (m_guide.exponentCyrillic // Only true in scientific float mode.
- && (tail.startsWith(u"\u0415") || tail.startsWith(u"E"))) {
+ && (tail.startsWith(u"\u0415", Qt::CaseInsensitive)
+ || tail.startsWith(u"E", Qt::CaseInsensitive))) {
++m_index;
return 'e';
}
diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
index 579a2fd8f7..959327551b 100644
--- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp
@@ -916,8 +916,12 @@ void tst_QLocale::toReal_data()
// may be some cross-over between these.
QTest::newRow("uk_UA Cyrillic E") << u"uk_UA"_s << u"4\u0415-3"_s << true << 4e-3; // Official
QTest::newRow("uk_UA Latin E") << u"uk_UA"_s << u"4E-3"_s << true << 4e-3;
+ QTest::newRow("uk_UA Cyrilic e") << u"uk_UA"_s << u"4\u0435-3"_s << true << 4e-3;
+ QTest::newRow("uk_UA Latin e") << u"uk_UA"_s << u"4e-3"_s << true << 4e-3;
QTest::newRow("ru_RU Latin E") << u"ru_RU"_s << u"4E-3"_s << true << 4e-3; // Official
QTest::newRow("ru_RU Cyrillic E") << u"ru_RU"_s << u"4\u0415-3"_s << true << 4e-3;
+ QTest::newRow("ru_RU Latin e") << u"ru_RU"_s << u"4e-3"_s << true << 4e-3;
+ QTest::newRow("ru_RU Cyrilic e") << u"ru_RU"_s << u"4\u0435-3"_s << true << 4e-3;
}
void tst_QLocale::stringToDouble_data()