replaceArabicNumber static method
Replace Arabic/Hindi numerals with English numerals
Converts Arabic-Indic digits (٠١٢٣٤٥٦٧٨٩) to Western Arabic numerals (0123456789)
Example:
NumberUtils.replaceArabicNumber('١٢٣'); // Returns: '123'
NumberUtils.replaceArabicNumber('١٢٣.٤٥'); // Returns: '123.45'
NumberUtils.replaceArabicNumber('السعر: ٩٩٩'); // Returns: 'السعر: 999'
Implementation
static String replaceArabicNumber(String input) {
const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
const arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
for (int i = 0; i < english.length; i++) {
input = input.replaceAll(arabic[i], english[i]);
}
return input;
}