Cocoa: Get the right zero digit for the locale

Change-Id: Ic23e541e1b12b3c94f8d191cb8fb0f76086b69a5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Andy Shaw 2019-05-02 08:49:37 +02:00
parent 513e29af1d
commit 047633a945

View File

@ -332,6 +332,17 @@ static QString macCurrencySymbol(QLocale::CurrencySymbolFormat format)
return QString();
}
static QString macZeroDigit()
{
QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
QCFType<CFNumberFormatterRef> numberFormatter =
CFNumberFormatterCreate(nullptr, locale, kCFNumberFormatterNoStyle);
static const int zeroDigit = 0;
QCFType<CFStringRef> value = CFNumberFormatterCreateStringWithValue(nullptr, numberFormatter,
kCFNumberIntType, &zeroDigit);
return QString::fromCFString(value);
}
#ifndef QT_NO_SYSTEMLOCALE
static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &arg)
{
@ -437,8 +448,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
case NegativeSign:
case PositiveSign:
case ZeroDigit:
break;
case ZeroDigit:
return QVariant(macZeroDigit());
case MeasurementSystem:
return QVariant(static_cast<int>(macMeasurementSystem()));