Assuming all your text is in a file and that English and persian translations are on different lines.
What you need to do is read each line from the file and check if it is ASCII or not.
How do you check that?
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
public class StringUtils {
static CharsetEncoder asciiEncoder =
Charset.forName("US-ASCII").newEncoder(); // or "ISO-8859-1" for ISO Latin 1
public static boolean isPureAscii(String v) {
return asciiEncoder.canEncode(v);
}
public static void main (String args[])
throws Exception {
String test = " برام ";
System.out.println(test + " isPureAscii() : " + StringUtils.isPureAscii(test));
test = "Real";
System.out.println(test + " isPureAscii() : " + StringUtils.isPureAscii(test));
/*
* output :
* برام isPureAscii() : false
* Real isPureAscii() : true
*/
}
}
solved find Special word from text and put to array [closed]