I already have this function fun replaceArabicNu...
# android
g
I already have this function fun replaceArabicNumbers(number: String): String{ return number .replace("٠", "0") .replace("١", "1") .replace("٢", "2") .replace("٣", "3") .replace("٤", "4") .replace("٥", "5") .replace("٦", "6") .replace("٧", "7") .replace("٨", "8") .replace("٩", "9") }
stackoverflow 2
🧵 2
e
1. one thread instead of multiple messages 2. just use ICU,
Transliterator.getInstance("Arabic-Latin").transliterate("٣٫١٤١٥٩٢٦٥٣٥٨") == "3,14159265358"
3. or just parse the number directly,
NumberFormat.getInstance(Locale("ar", "")).parse("٣٫١٤١٥٩٢٦٥٣٥٨") == 3.14159265358
4. 😶
g
need to add any library to have this Transliterator?
yeah, now I see it's not kotlin emoji, dark mode is hard to see, sorry
e
if you are minSdk=29 there is android.icu.text.Transliterator; otherwise com.ibm.icu.text.Transliterator is available in the
com.ibm.icu:icu4j
artifact
g
ok, I will try, thank you
j
Sequence though is a great docs page, my compliments to the brains who wrote it: https://kotlinlang.org/docs/sequences.html#iterable
👍 1
g
Really great, thank you