android - 我如何检测字符串中的语言类型?

标签 android

我有一个 SMS 计数器,可以计算输入的字符数;

我想当用户输入 English char(English chars + sings + numbers) ,计数变量做++ 到 Number: 160,

但是,如果总共有一个 Persian 字符,计算变量 do++ 到 Number: 70

我该怎么办?

我发现这段代码:var ucs2 = text.search(/[^\x00-\x7D]/)php 中返回什么字符用户;波斯字符或英语。

Java 中的等效代码——什么是 AndroidÏ

 private final TextWatcher TextWatcher_Method = new TextWatcher() 
  { 
     public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
        {
            cnt2=matn_counter.length();

            TextView counter=(TextView)findViewById(R.id.txt_counter);  

            cnt1=(int) Math.ceil(cnt2/6);
            Integer cnt3=(cnt2%6);

            counter.setText(Integer.toString(cnt1)+"/"+Integer.toString(cnt3));

        }
  }

最佳答案

您可以使用 Bidi类(class)。 有关更多信息,请查看 this answer请。

关于android - 我如何检测字符串中的语言类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19132128/

相关文章:

java - Android 中的线程和崩溃

带有基于自定义操作提供程序的垂直(旋转)文本项的 Android ActionBar 菜单

android - 从android上的retrofit方法返回Callable

android - SQLite 没有创建第二个表

Eclipse 中的 Android SDK DDMS 无法识别我的 Android 手机

android - 当 ViewGroup 的 sibling 消失时,我如何才能使 ViewGroup 的 child match_parent ?

database - Android,存储几个WAV文件

android - 每个元素都很大 - 拉伸(stretch)(字体、图片、 map ...)

android - AOSP 阻止安装来自未知来源的应用程序

java - 当外部对象用final声明时,为什么匿名内部类会调用外部对象