- CJK_UNIFIED_IDEOGRAPHS: 基本的中日韩统一表意文字。
- CJK_COMPATIBILITY_IDEOGRAPHS: 中日韩兼容表意文字。
- CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A: 中日韩统一表意文字扩展 A 区。
- GENERAL_PUNCTUATION: 通用标点符号。
- CJK_SYMBOLS_AND_PUNCTUATION: 中日韩符号和标点符号。
- HALFWIDTH_AND_FULLWIDTH_FORMS: 半角和全角字符。
private fun isChinese(c: Char): Boolean {
val ub = Character.UnicodeBlock.of(c)
return when (ub) {
Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS,
Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS,
Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A,
Character.UnicodeBlock.GENERAL_PUNCTUATION,
Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION,
Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS -> true
else -> false
}
}