Open
Description
Description
Decimal.FormatStyle
does not always respect the locale's decimalSeparator, also, the same error occurs with FloatingPointFormatStyle
Steps to reproduce
1- Set the iPhone region to Germany.
2- Set the iPhone language to English (US).
3- Set the Number Format decimal separator to period instead of the default comma.
Expected behavior
let number: Decimal = 1.5
let newFormatter = Decimal.FormatStyle.number
let newResult = number.formatted(newFormatter) // 1,5 ❌
let oldFormatter = NumberFormatter()
oldFormatter.numberStyle = .decimal
let oldResult = oldFormatter.string(from: number as NSNumber)! // 1.5 ✅
Environment
- Swift version: 5.7
- Xcode version: 14.2
- Deployment target: iOS 16.3