Is Chinese Character - Java Internationalization

Java examples for Internationalization:Chinese

Description

Is Chinese Character

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        char c = 'a';
        System.out.println(IsChinese(c));
    }/*from   w ww  .  j a  v a2 s  . com*/

    private static final 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 final boolean IsChinese(String strName) {
        char[] ch = strName.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            char c = ch[i];
            if (IsChinese(c)) {
                return true;
            }
        }
        return false;
    }
}

Related Tutorials