我怎么能检测语言的类型,一个字符串? [英] How i can Detect type of language in a string?

查看:94
本文介绍了我怎么能检测语言的类型,一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问改变。

我来自伊朗和放大器;我们的文字语言为波斯语;

我有计数输入的字符短信计数器;

我想,当用户键入英语字符(英文字符+演唱+号),计数变量做++来编号:160

但是,如果在所有的有RA 波斯字符,计数变量做++来号码:70

我应该做的。

我被罚,这code: VAR UCS2 = text.search(/ [^ \ x00- \ x7D] /) PHP 返回什么字符的用户;波斯字符或英文。

相当于code在Java中 - Android是什么

  

 私人最终TextWatcher TextWatcher_Method =新TextWatcher()
  {
     公共无效onTextChanged(CharSequence的arg0中,诠释ARG1,诠释ARG2,INT ARG3)
        {
            CNT2 = matn_counter.length();

            TextView的计数器=(TextView中)findViewById(R.id.txt_counter);

            CNT1 =(INT)Math.ceil(CNT2 / 6);
            整数CNT3 =(CNT2%6);

            counter.setText(Integer.toString(CNT1)+/+ Integer.toString(CNT3));

        }
  }
 

解决方案

您可以使用的比迪烟类。 更多信息看这个答案吧。

Question changed.

I'm From Iran & our Written language is Persian;

i have a SMS counter that count typed character;

i wanna when user type English char(English chars + sings + numbers) ,counting Variable do ++ to Number: 160,

But , if In all there r a Persian char , counting Variable do ++ to Number: 70

what i should to do.

I Fined that this code : var ucs2 = text.search(/[^\x00-\x7D]/) in php return What character user ; Persian char or English.

The equivalent code in Java - What is 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));

        }
  }

解决方案

You can use Bidi class. for more info look at this answer please.

这篇关于我怎么能检测语言的类型,一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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