AnyCallStar的ChinaUnix博客
AnyCallStar
全部博文(45)
2011年(1)
2008年(44)
1luyutao
moshangx
gjhkevin
lonelyso
george_l
chb128
5467189
Du_ruoli
tlang191
分类: Java
2008-07-30 09:53:33
public class IsChineseOrEnglish { // GENERAL_PUNCTUATION 判断中文的“号 // CJK_SYMBOLS_AND_PUNCTUATION 判断中文的。号 // HALFWIDTH_AND_FULLWIDTH_FORMS 判断中文的,号 public static boolean isChinese(char c) { Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS){ return true; } return false; } public static void isChinese(String strName) { char[] ch = strName.toCharArray(); for (int i = 0; i < ch.length; i++) { char c = ch[i]; if(isChinese(c)==true){ System.out.println(isChinese(c)); return; }else{ System.out.println(isChinese(c)); return ; } } } public static void main(String[] args){ isChinese("zhongguo"); isChinese("中国"); } }
上一篇:常用java实现简单的txt转换xml(2)
下一篇:财富与健康的思考?(转)
登录 注册