Is string containing Chinese - Android Internationalization

Android examples for Internationalization:Chinese

Description

Is string containing Chinese

Demo Code

import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean containChinese(String s) {
        if (null == s) {
            return false;
        }//from  ww  w .j a va2s .  c  om

        Pattern pattern = Pattern.compile(".*[\u4e00-\u9fbb]+.*");
        Matcher matcher = pattern.matcher(s);
        return matcher.matches();
    }

}

Related Tutorials