convertArabicNumbersToEnglish method
Converts Arabic numerals in the input string to their English equivalents.
This function takes a string containing Arabic numerals and returns a new string where all Arabic numerals have been replaced with their English counterparts.
Example:
String result = convertArabicNumbersToEnglish("١٢٣");
print(result); // Output: "123"
- Parameter input: The string containing Arabic numerals to be converted.
- Returns: A new string with Arabic numerals converted to English numerals.
Implementation
String convertArabicNumbersToEnglish(String input) {
const arabicNumbers = '٠١٢٣٤٥٦٧٨٩';
const englishNumbers = '0123456789';
return input.split('').map((char) {
int index = arabicNumbers.indexOf(char);
if (index != -1) {
return englishNumbers[index];
}
return char;
}).join('');
}