我有一台热敏打印机,只支持繁体中文字符而非拉丁字符。有没有办法检查给定的Unicode CJK字符是否是Big-5编码下有效的繁体中文字符?
更新:
这是我用来检查字符串是否具有Unicode CJK的方法。
public static boolean isChineseText(String s) {
for (int i = 0; s != null && s.length() > 0 && i < s.length(); i++) {
char ch = s.charAt(i);
Character.UnicodeBlock block = Character.UnicodeBlock.of(ch);
if (Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS.equals(block)
|| Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
.equals(block)
|| Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
.equals(block)) {
//Here, I want to check if its a Traditional Chinese character under Big-5
return true;
}
}
return false;
}