Commit 6a1bab19 authored by Alexander Lohnau's avatar Alexander Lohnau 💬 Committed by Nate Graham
Browse files

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
parent c6559459
......@@ -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") << "2³"
<< "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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment