summaryrefslogtreecommitdiffstats
path: root/src/org/madore/android/unicodeMap/UnicodeCharacter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/madore/android/unicodeMap/UnicodeCharacter.java')
-rw-r--r--src/org/madore/android/unicodeMap/UnicodeCharacter.java71
1 files changed, 49 insertions, 22 deletions
diff --git a/src/org/madore/android/unicodeMap/UnicodeCharacter.java b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
index 166229f..f3ff6d1 100644
--- a/src/org/madore/android/unicodeMap/UnicodeCharacter.java
+++ b/src/org/madore/android/unicodeMap/UnicodeCharacter.java
@@ -226,18 +226,42 @@ public class UnicodeCharacter implements UnicodeDisplayable {
}
public static enum SpecialRange {
- CJK_IDEOGRAPH_EXTENSION_A(0x3400, 0x4DB5),
- CJK_IDEOGRAPH(0x4E00, 0x9FCB),
- HANGUL_SYLLABLE(0xAC00, 0xD7A3),
- CJK_IDEOGRAPH_EXTENSION_B(0x20000, 0x2A6D6),
- CJK_IDEOGRAPH_EXTENSION_C(0x2A700, 0x2B734);
+ CJK_IDEOGRAPH_EXTENSION_A(0x3400, 0x4DB5, Category.OTHER_LETTER) {
+ public String getName(int codePoint) {
+ return cjkIdeographName(codePoint);
+ }
+ },
+ CJK_IDEOGRAPH(0x4E00, 0x9FCB, Category.OTHER_LETTER) {
+ public String getName(int codePoint) {
+ return cjkIdeographName(codePoint);
+ }
+ },
+ HANGUL_SYLLABLE(0xAC00, 0xD7A3, Category.OTHER_LETTER) {
+ public String getName(int codePoint) {
+ return hangulSyllableName(codePoint);
+ }
+ },
+ CJK_IDEOGRAPH_EXTENSION_B(0x20000, 0x2A6D6, Category.OTHER_LETTER) {
+ public String getName(int codePoint) {
+ return cjkIdeographName(codePoint);
+ }
+ },
+ CJK_IDEOGRAPH_EXTENSION_C(0x2A700, 0x2B734, Category.OTHER_LETTER) {
+ public String getName(int codePoint) {
+ return cjkIdeographName(codePoint);
+ }
+ };
protected final int from; protected final int to;
- SpecialRange(int from, int last) {
+ protected Category category;
+ SpecialRange(int from, int last, Category category) {
this.from = from;
this.to = last+1;
+ this.category = category;
}
public int getFrom() { return this.from; }
public int getTo() { return this.to; }
+ public Category getCategory() { return this.category; }
+ public String getName(int codePoint) { return null; }
public boolean belongs(int codePoint) {
return ( codePoint>=this.from && codePoint<this.to );
}
@@ -249,7 +273,7 @@ public class UnicodeCharacter implements UnicodeDisplayable {
public boolean inside(int from, int to) {
return ( from >= this.from && to <= this.to );
}
- public static boolean isCjkUnifiedIdeograph(int codePoint) {
+ public static boolean isCjkIdeograph(int codePoint) {
return ( CJK_IDEOGRAPH.belongs(codePoint)
|| CJK_IDEOGRAPH_EXTENSION_A.belongs(codePoint)
|| CJK_IDEOGRAPH_EXTENSION_B.belongs(codePoint)
@@ -258,28 +282,31 @@ public class UnicodeCharacter implements UnicodeDisplayable {
public static boolean isHangulSyllable(int codePoint) {
return HANGUL_SYLLABLE.belongs(codePoint);
}
- public static String cjkUnifiedIdeographName(int codePoint) {
- if ( ! isCjkUnifiedIdeograph(codePoint) )
- return null;
+ protected static String cjkIdeographName(int codePoint) {
return String.format("CJK UNIFIED IDEOGRAPH-%04X", codePoint);
}
- public static String hangulSyllableName(int codePoint) {
- if ( ! isHangulSyllable(codePoint) )
- return null;
+ protected static String hangulSyllableName(int codePoint) {
int index = codePoint - HANGUL_SYLLABLE.getFrom();
final int tCount = 28; final int nCount = 21*tCount;
int l = index/nCount;
int v = (index%nCount)/tCount;
int t = index%tCount;
- final String[] partL = { "G", "GG", "N", "D", "DD", "R", "M", "B", "BB", "S",
- "SS", "", "J", "JJ", "C", "K", "T", "P", "H" };
- final String[] partV = { "A", "AE", "YA", "YAE", "EO", "E", "YEO", "YE", "O", "WA",
- "WAE", "OE", "YO", "U", "WEO", "WE", "WI", "YU", "EU", "YI",
- "I" };
- final String[] partT = { "", "G", "GG", "GS", "N", "NJ", "NH", "D", "L", "LG",
- "LM", "LB", "LS", "LT", "LP", "LH", "M", "B", "BS", "S",
- "SS", "NG", "J", "C", "K", "T", "P", "H" };
- return String.format("HANGUL SYLLABLE %s%s%s", partL[l], partV[v], partT[t]);
+ final String[] partL = {
+ "G", "GG", "N", "D", "DD", "R", "M", "B", "BB", "S",
+ "SS", "", "J", "JJ", "C", "K", "T", "P", "H"
+ };
+ final String[] partV = {
+ "A", "AE", "YA", "YAE", "EO", "E", "YEO", "YE", "O", "WA",
+ "WAE", "OE", "YO", "U", "WEO", "WE", "WI", "YU", "EU", "YI",
+ "I"
+ };
+ final String[] partT = {
+ "", "G", "GG", "GS", "N", "NJ", "NH", "D", "L", "LG",
+ "LM", "LB", "LS", "LT", "LP", "LH", "M", "B", "BS", "S",
+ "SS", "NG", "J", "C", "K", "T", "P", "H"
+ };
+ return String.format("HANGUL SYLLABLE %s%s%s",
+ partL[l], partV[v], partT[t]);
}
}