QLocale::toCurrencyString(negative_number, Symbol) does not return correct value
-
Hi folks, I am woking on a codebase and was looking to migrate from qt5.12 to qt5.15. However I noticed that there is something off with QLocale::toCurrencyString returning wrong output on qt5.15.10 when I pass in a negative number. This affects a few Locals, I tested this with an imperfect program:
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); double amount = (-1001) / 1000.0; for(int i = QLocale::AnyLanguage; i<QLocale::Buginese; ++i){ QLocale locale_(static_cast<QLocale::Language>(i)); QString currencySymbol = locale_.currencySymbol(QLocale::CurrencySymbol); qDebug() << "Price is: " << locale_.toCurrencyString(amount, currencySymbol); } return a.exec(); }
Sample of the results are as below:
Price is: "Br-1.00" Price is: "ETB -1.00" Price is: "(R1,00)" Price is: "(1 Lekë)" Price is: "(ብር1.00)" Price is: "-١٫٠٠ ج.م.\u200F" Price is: "-1,00 ֏" Price is: "₹ -১.০০" Price is: "-£1.00" Price is: "-1,00 ₼" Price is: "₽ -1.00" Price is: "(1,00 €)" Price is: "(১.০০৳)" Price is: "Nu.-༡.༠༠" Price is: "-£1.00" Price is: "-£1.00" Price is: "-1,00 €" Price is: "(1,00 лв.)" Price is: "K -၁" Price is: "-1,00 Br" Price is: "(1,00៛)" Price is: "(1,00 €)" Price is: "(¥1.00)" Price is: "€ -1.00" Price is: "−1,00 HRK" Price is: "-1,00 Kč" Price is: "-1,00 kr." Price is: "(€ 1,00)" Price is: "($1.00)" Price is: " −1,00" Price is: "(1,00 €)" Price is: "(1,00 kr)" Price is: "-£1.00" Price is: "−1,00 €" Price is: "(1,00 €)" Price is: "(€ 1,00)" Price is: "(£1.00)" Price is: "-1,00 €" Price is: "-1,00 ₾" Price is: "-1,00 €" Price is: "-1,00 €" Price is: "kr.−1,00"
Is this the expected behaviour or is there something off? If it is the default behaviour is there a way to get the actual correct values with the correct signs and without the parenthesis like we had on qt5.12
-
Hi folks, I am woking on a codebase and was looking to migrate from qt5.12 to qt5.15. However I noticed that there is something off with QLocale::toCurrencyString returning wrong output on qt5.15.10 when I pass in a negative number. This affects a few Locals, I tested this with an imperfect program:
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); double amount = (-1001) / 1000.0; for(int i = QLocale::AnyLanguage; i<QLocale::Buginese; ++i){ QLocale locale_(static_cast<QLocale::Language>(i)); QString currencySymbol = locale_.currencySymbol(QLocale::CurrencySymbol); qDebug() << "Price is: " << locale_.toCurrencyString(amount, currencySymbol); } return a.exec(); }
Sample of the results are as below:
Price is: "Br-1.00" Price is: "ETB -1.00" Price is: "(R1,00)" Price is: "(1 Lekë)" Price is: "(ብር1.00)" Price is: "-١٫٠٠ ج.م.\u200F" Price is: "-1,00 ֏" Price is: "₹ -১.০০" Price is: "-£1.00" Price is: "-1,00 ₼" Price is: "₽ -1.00" Price is: "(1,00 €)" Price is: "(১.০০৳)" Price is: "Nu.-༡.༠༠" Price is: "-£1.00" Price is: "-£1.00" Price is: "-1,00 €" Price is: "(1,00 лв.)" Price is: "K -၁" Price is: "-1,00 Br" Price is: "(1,00៛)" Price is: "(1,00 €)" Price is: "(¥1.00)" Price is: "€ -1.00" Price is: "−1,00 HRK" Price is: "-1,00 Kč" Price is: "-1,00 kr." Price is: "(€ 1,00)" Price is: "($1.00)" Price is: " −1,00" Price is: "(1,00 €)" Price is: "(1,00 kr)" Price is: "-£1.00" Price is: "−1,00 €" Price is: "(1,00 €)" Price is: "(€ 1,00)" Price is: "(£1.00)" Price is: "-1,00 €" Price is: "-1,00 ₾" Price is: "-1,00 €" Price is: "-1,00 €" Price is: "kr.−1,00"
Is this the expected behaviour or is there something off? If it is the default behaviour is there a way to get the actual correct values with the correct signs and without the parenthesis like we had on qt5.12
@Melu said in QLocale::toCurrencyString(negative_number, Symbol) does not return correct value:
qt5.15.10
Since this is a commercial-only version you should ask the Qt support.
-
@Melu said in QLocale::toCurrencyString(negative_number, Symbol) does not return correct value:
qt5.15.10
Since this is a commercial-only version you should ask the Qt support.
@Christian-Ehrlicher Thanks for the response. I will do so. I wanted to note that the same issue is on the open source version 5.15.5 downloaded from: https://download.qt.io/official_releases/qt/5.15/5.15.5/single.
-
@Melu said in QLocale::toCurrencyString(negative_number, Symbol) does not return correct value:
[..] However I noticed that there is something off with QLocale::toCurrencyString returning wrong output on qt5.15.10 when I pass in a negative number.
I think this is behavior described in https://bugreports.qt.io/browse/QTBUG-89383 . So it seems the parenthesis are used in 'accounting format' for some locales.
-
@Melu said in QLocale::toCurrencyString(negative_number, Symbol) does not return correct value:
[..] However I noticed that there is something off with QLocale::toCurrencyString returning wrong output on qt5.15.10 when I pass in a negative number.
I think this is behavior described in https://bugreports.qt.io/browse/QTBUG-89383 . So it seems the parenthesis are used in 'accounting format' for some locales.