请教一个简单的问题,up有分,谢谢

hu1dao 2004-08-22 05:59:39
请问如何判断一个TextField中用户输入的是中文还是英文,谢谢
...全文
76 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Arias 2004-08-23
  • 打赏
  • 举报
回复
直接在输入的时候根据你的需要来控制TextField的输入代码就可以那,一定要在别人输入后判断吗??
charlie0895 2004-08-22
  • 打赏
  • 举报
回复
正好学习的机会
梦想家起飞 2004-08-22
  • 打赏
  • 举报
回复
java.util.regex

Class Pattern

java.lang.Object
java.util.regex.Pattern

All Implemented Interfaces:
Serializable

Predefined character classes
. Any character (may or may not match line terminators)
\d A digit: [0-9]
\D A non-digit: [^0-9]
\s A whitespace character: [ \t\n\x0B\f\r]
\S A non-whitespace character: [^\s]
\w A word character: [a-zA-Z_0-9]
\W A non-word character: [^\w]
梦想家起飞 2004-08-22
  • 打赏
  • 举报
回复
用正则表达式应该也可以。判断一个字符串是不是全部为字母就行了。
artmouse 2004-08-22
  • 打赏
  • 举报
回复
提一个思路,
先分成一个一个字符
然后取得字符的对应ascII码

Character 对象有个digit方法

digit
public static int digit(char ch,
int radix)Returns the numeric value of the character ch in the specified radix.
Parameters:
ch - the character to be converted.
radix - the radix.
Returns:
the numeric value represented by the character in the specified radix.
Since:
JDK1.0

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧