java判断字符是否是中文的方法

java | 2019-09-13 10:02:39

java判断字符是否是中文的方法:干货分享,这个方法可以直接复制调用,用于判断字符是否是中文。


private 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.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
                                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
                                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) {
                        return true;
                }
                return false;
        }


登录后即可回复 登录 | 注册
    
关注编程学问公众号