Hi there
The behaviour of using Locale(identifier: "ar")
with NumberFormatter.locale
appears to have changed between iOS 17 and iOS 18.
Is this expected?
Steps to reproduce
import UIKit
func numberFormatter(withlocaleString localeString: String) -> NumberFormatter {
let locale = Locale(identifier: localeString)
let numberFormatter = NumberFormatter()
numberFormatter.locale = locale
return numberFormatter
}
let numbers = 0...9
let localeDigits = numbers
let ar_digits = localeDigits.compactMap {
numberFormatter(withlocaleString: "ar").string(for: $0)?.first
}
print(ar_digits)
Results
The results show:
****
numbering system on iOS 17latn
numbering system on iOS 18.
iOS 17 | ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"] |
iOS 18 | ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] |
What you’re observing is expected. The default numbering system for Arabic did change to use Western Arabic (Latin) digits in iOS 18.
With that said, for any region for which Arabic is a widely-spoken language, the numbering system has not changed. For example, if you initialize Locale
with ar_SA
, you’ll note that it continues to use Eastern Arabic (Arabic-Indic) digits.
Additionally, it’s worth noting that the numbering system is a user-configurable setting in Language & Region settings, and when the user overrides it away from the default for that region, the locale identifier will convey this with a subtag, e.g. ar_US@numbers=arab
is an Arabic (U.S.) locale with Eastern Arabic digits.
Hope this helps!