diff --git a/runners/calculator/autotests/calculatorrunnertest.cpp b/runners/calculator/autotests/calculatorrunnertest.cpp index bcc1163b7..eeb31d1a5 100644 --- a/runners/calculator/autotests/calculatorrunnertest.cpp +++ b/runners/calculator/autotests/calculatorrunnertest.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") << "2³" + << "8"; // BUG: 435932 #endif QTest::newRow("hex to decimal lower case") << "0xf" << "15"; diff --git a/runners/calculator/qalculate_engine.cpp b/runners/calculator/qalculate_engine.cpp index 707f27551..0ae965219 100644 --- a/runners/calculator/qalculate_engine.cpp +++ b/runners/calculator/qalculate_engine.cpp @@ -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();