From 4768fcf836f1eb0f59ab62a29eb821b433a239c1 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 9 May 2023 11:57:12 +0200 Subject: [PATCH] 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 Reviewed-by: Ievgenii Meshcheriakov --- src/corelib/text/qlocale.cpp | 3 ++- tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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()