calculatorrunner: Fix superscripted numbers

Use toLocal8Bit instead of toLatin1 see https://doc.qt.io/qt-5/qstring.html#toLatin1.
Otherwise the superscripted numbers would not be correctly converted.

BUG: 435932
wilder-5.22
Alexander Lohnau 5 years ago committed by Nate Graham
parent c655945913
commit 6a1bab19af
  1. 2
      runners/calculator/autotests/calculatorrunnertest.cpp
  2. 3
      runners/calculator/qalculate_engine.cpp

@ -50,6 +50,8 @@ void CalculatorRunnerTest::testQuery_data()
QTest::newRow("x as multiplication sign") << "25x4" << "100";
#ifdef ENABLE_QALCULATE
QTest::newRow("single digit factorial") << "5!" << "120";
QTest::newRow("superscripted number") << ""
<< "8"; // BUG: 435932
#endif
QTest::newRow("hex to decimal lower case") << "0xf" << "15";

@ -85,7 +85,8 @@ QString QalculateEngine::evaluate(const QString &expression, bool *isApproximate
}
QString input = expression;
QByteArray ba = input.replace(QChar(0xA3), "GBP").replace(QChar(0xA5), "JPY").replace('$', "USD").replace(QChar(0x20AC), "EUR").toLatin1();
// Make sure to use toLocal8Bit, the expression can contain non-latin1 characters
QByteArray ba = input.replace(QChar(0xA3), "GBP").replace(QChar(0xA5), "JPY").replace('$', "USD").replace(QChar(0x20AC), "EUR").toLocal8Bit();
const char *ctext = ba.data();
CALCULATOR->terminateThreads();

Loading…
Cancel
Save