如何确定字符串是英语还是波斯语? [英] How to determine a string is english or persian?

查看:160
本文介绍了如何确定字符串是英语还是波斯语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单中有edittext,我想当用户输入文本到edittext我的程序检测到语言插入到edittext

I have edittext in form, I wanna when user input text in to edittext my program detect wich language inserted to edittext

有没有办法确定字符串是英语或波斯语?

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

我发现此代码为阿拉伯语

I found this code for arabic

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 can I change this code for persian?

推荐答案

所有可能的波斯语(也用于乌尔都语)字母的Unicode范围:

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

所以如果你想要不要错过任何字符检查所有范围。希望能帮到你。

So if you want don't miss any char check all ranges. Hope helps you.

这篇关于如何确定字符串是英语还是波斯语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆