From 907aaba93d0c325e98cf91a2651c6f3e1654dedf Mon Sep 17 00:00:00 2001 From: Alexander Shalamov Date: Mon, 2 Sep 2019 22:51:37 +0300 Subject: [darwin] Reset number formatter digits for currency style As we are using singleton formatter, fraction digits must be reset when number formatter is used when initialized for decimal / currency style. --- platform/darwin/src/string_nsstring.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/darwin/src/string_nsstring.mm b/platform/darwin/src/string_nsstring.mm index 096ed2b212..382a2acf33 100644 --- a/platform/darwin/src/string_nsstring.mm +++ b/platform/darwin/src/string_nsstring.mm @@ -43,6 +43,10 @@ std::string formatNumber(double number, const std::string& localeId, const std:: numberFormatter.maximumFractionDigits = maxFractionDigits; numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; } else { + // Reset fraction digits to NSNumberFormatter's default values, so that the + // system will choose formatting based on number formatter locale. + numberFormatter.minimumFractionDigits = 0; + numberFormatter.maximumFractionDigits = 0; numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle; } NSString *formatted = [numberFormatter stringFromNumber:@(number)]; -- cgit v1.2.1