Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS : 4E00-9FBF:CJK 统一表意符号
Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS :F900-FAFF:CJK 兼容象形文字 Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A :3400-4DBF:CJK 统一表意符号扩展 A
CJK的意思是“Chinese,Japanese,Korea”的简写 ,实际上就是指中日韩三国的象形文字的Unicode编码
Character.UnicodeBlock.GENERAL_PUNCTUATION :2000-206F:常用标点 Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION :3000-303F:CJK 符号和标点 Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS :FF00-FFEF:半角及全角形式
判断字符中是否包含中文字符时,可以用
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;
}
分享到:
相关推荐
Character.UnicodeBlock 中 cjk 的说明详解 Character.UnicodeBlock 是 Java 中的一个枚举类型,用于描述 Unicode 字符集中的 Unicode 块(Block)。在 Unicode 中,每个 Unicode 块都有一个唯一的名称和一个唯一...
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS || ub =...
if (Character.UnicodeBlock.of(character) == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS) { // 输入的是中文字符 } ``` 5. **阻止非中文输入**: 如果输入的不是中文字符,我们可以在`onTextChanged()`...
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT) { return true; } return false; } ``` 2. **使用 `UnicodeScript` 判断汉字(仅限 JDK 1.7 及以上版本):** ```java ...
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == ...
总结来说,Java中判断一个字符串是否包含中文字符,应使用`Character.UnicodeBlock`来检查字符的Unicode区块,以确保涵盖所有可能的中文字符和相关符号,而不仅仅是基于简单的Unicode编码区间。这种方法能提供更精确...
ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character....
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS || ub == Character...
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == ...
JAVA 统计字符串中中文、英文、数字、空格、特殊字符的个数 ...在 Java 中,我们可以使用 Unicode 编码和 Character.UnicodeBlock 来统计字符串中不同的字符个数。这可以满足我们在日常编程工作中的需求。
* CJK.UNIFIED_IDEOGRAPHS:4E00-9FBF,用于表示中文、日文和韩文字符 * CJK_COMPATIBILITY_IDEOGRAPHS:F900-FAFF,用于表示 CJK 兼容象形文字 * CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A:3400-4DBF,用于表示 CJK ...
Character.UnicodeBlock.of(s.charAt(i)).equals(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS)) { return false; } } } return true; } ``` 在这个例子中,我们创建了一个`TextWatcher`并在`...
在上面的代码中,我们使用 Character.UnicodeBlock 枚举类型来判断字符是否为中文。如果字符属于 CJK_UNIFIED_IDEOGRAPHS、CJK_COMPATIBILITY_IDEOGRAPHS、CJK_COMPATIBILITY_FORMS、CJK_RADICALS_SUPPLEMENT、CJK_...