I have multiple strings with different formats that I need to display in some TextViews. I have no control over the length or the format of these strings. They could have numbers obly, text only, or a combination of both.
My goal is to display the strings in some TextViews, and in the process, convert any English numbers to Arabic numbers.
The following examples should clarify what I mean:
original string >> converted string
=====================================
test 123 >> test ١٢٣
test >> test
123 >> ١٢٣
I started by doing this:
txtView.setText(String.format(locale, "%d", fulltext));
but this assumes you have numbers only in your fulltext
string.
Could you suggest how to work around this?
Lets say your fulltext string is this
String fulltext = "1a2b3c";
Replace the instances of all of the numbers with the corresponding Arabic numbers
fulltext = fulltext.replace("1","١").replace("2","٢").replace("3","٣");
etc. Hopefully this is what you mean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With