is Contain Chinese by checking char value range - Android Internationalization

Android examples for Internationalization:Chinese

Description

is Contain Chinese by checking char value range

Demo Code

import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isContainChinese(String str) {
        if (str == null || str.trim().length() <= 0) {
            return false;
        }//w  ww.j  a va  2 s  .c o  m

        int len = str.length();
        for (int i = 0; i < len; i++) {
            char word = str.charAt(i);
            if ((word >= 0x4e00) && (word <= 0x9fbb)) {
                return true;
            }
        }
        return false;
    }

}

Related Tutorials