How can I convert Persian/Arabic numbers to English numbers with a simple function?
arabicNumbers = ["١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩", "٠"]
persianNumbers = ["۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹", "۰"]
It is the same schema, but the code pages are different.
Use this simple function to convert your string
Be careful, in this code the persian numbers codepage are different with the arabian numbers.
Example
Refrence
this is a simple way to do that:
an example:
Here is how I'd do it:
Transforms any Persian or Arabic (or mixed) number to "English" numbers (Hindu–Arabic numerals)
Short and easy!
You could do something like this that uses the index of the number within the string to do the conversion:
Or map using a object like this: