我有一个 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/