I'm trying to make a method to detect strings written in right to left languages in Java. I've come up with this question doing something similar in C#.
Now I need to have something like that but written in Java.
Any help is appreciated.
The Java String contains() method is used to check whether the specific set of characters are part of the given string or not. It returns a boolean value true if the specified characters are substring of a given string and returns false otherwise. It can be directly used inside the if statement.
I came up with the following code:
char[] chars = s.toCharArray();
for(char c: chars){
if(c >= 0x600 && c <= 0x6ff){
//Text contains RTL character
break;
}
}
It's not a very efficient or for that matter an accurate way but can give one ideas.
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