How to determine if a string is English or Persian?


Saeed Hashemi

I have an edittext of a form, and when the user enters text into the edittext, I want the program to detect which language the edittext is inserted in.

Is there a way to determine if a string is English or Persian?

I found this arabic code

public static boolean isProbablyArabic(String s) {
for (int i = 0; i < Character.codePointCount(s, 0, s.length()); i++) {
    int c = s.codePointAt(i);
    if (c >= 0x0600 && c <=0x06E0)
        return true;
}
return false;
}

But how to change this code for Persian?

Guido Mocha

All possible Unicode ranges for Persian (also for Urdu) letters:

Related


How to determine if a string is English or Persian?

Saeed Hashemi I have an edittext of a form, and when the user enters text into the edittext, I want the program to detect which language the edittext is inserted in. Is there a way to determine if a string is English or Persian? I found this arabic code public

Check if string is Persian or English

Arash Moeen I have a webview that will load a string from a URL, I'm not sure if this is correct, but all I want to do is check if the string is in persian, so I change the webview's text alignment to rtl otherwise, if it's english, then change it to ltr. Is i

How to determine if a string is English or Arabic?

Victor S: Is there a way to determine if a string is English or Arabic? Eyal Schneider: Here is the simple logic I just tried: public static boolean isProbablyArabic(String s) { for (int i = 0; i < s.length();) { int c = s.codePointAt(i);

How to determine if a string is English or Arabic?

Victor S: Is there a way to determine if a string is English or Arabic? Eyal Schneider: Here is the simple logic I just tried: public static boolean isProbablyArabic(String s) { for (int i = 0; i < s.length();) { int c = s.codePointAt(i);

How to determine if a string is an English word?

graphtheory12345678 I have an input string, some of which do not contain actual words (e.g. it contains mathematical formulas such as x^2 = y_2 + 4. I want a way to split the input string by whether there are substrings of actual English words. E.g: If my stri

How to determine if a string is English or Arabic?

Victor S: Is there a way to determine if a string is English or Arabic? Eyal Schneider: Here is the simple logic I just tried: public static boolean isProbablyArabic(String s) { for (int i = 0; i < s.length();) { int c = s.codePointAt(i);

How to determine if a string is an English word?

graphtheory12345678 I have an input string, some of which do not contain actual words (e.g. it contains mathematical formulas such as x^2 = y_2 + 4. I want a way to split the input string by whether there are substrings of actual English words. E.g: If my stri

How to determine if a string is an English word?

graphtheory12345678 I have an input string, some of which do not contain actual words (e.g. it contains mathematical formulas such as x^2 = y_2 + 4. I want a way to split the input string by whether there are substrings of actual English words. E.g: If my stri

How to determine if a string is an English word?

graphtheory12345678 I have an input string, some of which do not contain actual words (e.g. it contains mathematical formulas such as x^2 = y_2 + 4. I want a way to split the input string by whether there are substrings of actual English words. E.g: If my stri

How to determine if a string is an English word?

graphtheory12345678 I have an input string, some of which do not contain actual words (e.g. it contains mathematical formulas such as x^2 = y_2 + 4. I want a way to split the input string by whether there are substrings of actual English words. E.g: If my stri

How to determine if a string is an English word?

graphtheory12345678 I have an input string, some of which do not contain actual words (e.g. it contains mathematical formulas such as x^2 = y_2 + 4. I want a way to split the input string by whether there are substrings of actual English words. E.g: If my stri

How to determine if a string is an English sentence or a code?

Ryan Consider the following two strings, the first is a code and the second is an English sentence (wording to be precise). How to detect that the first is code and the second is not. 1. for (int i = 0; i < b.size(); i++) { 2. do something in English (not nece

How to determine if a string is an English sentence or a code?

Ryan Consider the following two strings, the first is a code and the second is an English sentence (wording to be precise). How to detect that the first is code and the second is not. 1. for (int i = 0; i < b.size(); i++) { 2. do something in English (not nece

How to determine if a string is an English sentence or a code?

Ryan Consider the following two strings, the first is a code and the second is an English sentence (wording to be precise). How to detect that the first is code and the second is not. 1. for (int i = 0; i < b.size(); i++) { 2. do something in English (not nece

How to separate mixed words (Persian and English) in python

retrieve data Hi, I have a dataset of strings, some strings contain mixed words like this: سلام12World دوربینdigital سال2012good ...and my desired output is: 12 سلام world دوربین digital 2012 سال good Here is my code: def spliteKeyWord(

How to separate mixed words (Persian and English) in python

retrieve data Hi, I have a dataset of strings, some strings contain mixed words like this: سلام12World دوربینdigital سال2012good ...and my desired output is: 12 سلام world دوربین digital 2012 سال good Here is my code: def spliteKeyWord(

Persian regex with english and persian numbers

M0RT3Z4 I have a regex pattern for validating persian characters: /^[\u0600-\u06FF\s]+$/ But it doesn't accept numbers. I don't know how to edit. I want this schema to accept English and Perisan/Farsi numbers. thanks for help Tim Biegeleisen Your pattern appe

Persian regex with english and persian numbers

M0RT3Z4 I have a regex pattern for validating persian characters: /^[\u0600-\u06FF\s]+$/ But it doesn't accept numbers. I don't know how to edit. I want this schema to accept English and Perisan/Farsi numbers. thanks for help Tim Biegeleisen Your pattern appe

Persian regex with english and persian numbers

M0RT3Z4 I have a regex pattern for validating persian characters: /^[\u0600-\u06FF\s]+$/ But it doesn't accept numbers. I don't know how to edit. I want this schema to accept English and Perisan/Farsi numbers. thanks for help Tim Biegeleisen Your pattern appe