qtqt5qtimeqlocale

How i could convert Persian numbers to English numbers using QLocale?


I want to convert Persian numbers to English numbers using QLocale, i wrote this code but it fail:

int main(void)
{
    QLocale english_number(QLocale::Language::English, QLocale::Country::UnitedStates);
    QTime time;

    time = english_number.toTime("۱۲:۳۲", "HH:mm");

    qDebug() << time;
}

Console output:

QTime(Invalid)

But it's possible to convert English numbers to Persian numbers:

QLocale persian_number(QLocale::Language::Persian, QLocale::Country::Iran);

time = persian_number.toTime("13:32", "HH:mm");

qDebug() << time;

Console Output:

QTime("13:32:00.000")

Where did i go wrong ?


Solution

  • I think it's a Qt Bug, for doing this before converting to QTime we need to convert Persian numbers to int and then convert to QTime.