Check if character is traditional Chinese in Big-5 (Java)?

I have a thermal printer that only supports traditional Chinese characters except Latin. Is there a way to verify that given the CJK character in Unicode, is it a valid traditional Big-5 encoded Chinese character?

UPDATE

Here is the method I use to check if String has 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; } 
+2
java android unicode chinese-locale big5
Dec 11 '14 at 2:40
source share
1 answer

The checks you did in your code (and Java itself) use Unicode encoding (not Big-5) to encode traditional Chinese text. See this page for a list of conversions between encodings or this site for a search.

There is no easy way that I know to verify that Chinese text is traditional. You can check if the characters are between 0xA140 and 0xF9D5 (apparently, the Big 5 range from the link above), but Unicode also has overlapping encoding in this range.

See also CJK Language Differentiation (Chinese, Japanese, Korean) on Android

0
Feb 01 '17 at 15:51
source share



All Articles