美文网首页
android 判断字符串中英文

android 判断字符串中英文

作者: 弄码哥nomag | 来源:发表于2016-03-13 16:53 被阅读0次

    http://www.yuanxingyuan.com/?id=15

    // 判断一个 char 是否是中文字符(CJK 分别代表中文、日文、韩文)
    public 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;
    }

    相关文章

      网友评论

          本文标题:android 判断字符串中英文

          本文链接:https://www.haomeiwen.com/subject/nnxflttx.html