Skip to content

Commit

Permalink
Cocoa: Get the right zero digit for the locale
Browse files Browse the repository at this point in the history
Change-Id: Ic23e541e1b12b3c94f8d191cb8fb0f76086b69a5
Reviewed-by: Tor Arne Vestbø <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
AndyShawQt committed May 2, 2019
1 parent 513e29a commit 047633a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/corelib/tools/qlocale_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -437,8 +448,9 @@ static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &

case NegativeSign:
case PositiveSign:
case ZeroDigit:
break;
case ZeroDigit:
return QVariant(macZeroDigit());

case MeasurementSystem:
return QVariant(static_cast<int>(macMeasurementSystem()));
Expand Down

0 comments on commit 047633a

Please sign in to comment.