I’m developing an app that has a feature to search a text (searchString ) in Arabic language if it is in a .txt file (.txt file is also in Arabic language).
Since Android doesn’t support Arabic 100%, String.indexof() doesn’t work properly. So, I thought, I would put the searchString into a Char[] array and instead of comparing the whole word, I compare every character. So I put the searchString into a char[] and start comparing the array to the String
Is it available anywhere a code that searches if the sequence that is in the char[] array is into a String?
example:
char[]={t,e,s,t} String1{qqwtestq} String2{qwqtqwe} -> String1:TRUE String2:FALSE
Thanks
indexOfandcontainsdon’t use character encoding of any sort and you can use characters which are not used in your character encoding for example. i.e. it is ignored for these functions.All String.indexOf() and contains do is compare character for character. I am not sure what behaviour you are expecting for 100% Arabic support. Here is a simplified version what the indexOf()/contains() does
Prints
Can you provide an example where this method doesn’t work?
EDIT: This test checks every possible character to see if indexOf behaves as expected. i.e. the same for every possible character.
Finds no discrepancies.