Java - Write code to check if a char is Chinese char by checking its Character.UnicodeBlock

Requirements

Write code to check if a char is Chinese char by checking its Character.UnicodeBlock

Demo

//package com.book2s;

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

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