- if ( (base > 0x1fff && base < 0x3000) || (base > 0xfe2f && base < 0xfe50)) {
- /* exclude these ranges from decomposition according to AFP 3.1 spec */
- /* page 97 */
- *out = base;
- out++;
- *outlen -= 2;
+ comblen = 0;
+
+ /* check ASCII first. this is frequent. */
+ if (base <= 0x007f) ;
+
+ /* Unicode Standard Annex #15 A10.2 Hangul Decomposition */
+ else if ((HANGUL_SBASE <= base) && (base < HANGUL_SBASE + HANGUL_SCOUNT)) {
+ hangul_sindex = base - HANGUL_SBASE;
+ base = HANGUL_LBASE + hangul_sindex / HANGUL_NCOUNT;
+ comb[MAXCOMBLEN-2] = HANGUL_VBASE + (hangul_sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT;
+
+ /* <L,V> */
+ if ((tjamo = HANGUL_TBASE + hangul_sindex % HANGUL_TCOUNT) == HANGUL_TBASE) {
+ comb[MAXCOMBLEN-1] = comb[MAXCOMBLEN-2];
+ comblen = 1;
+ }
+
+ /* <L,V,T> */
+ else {
+ comb[MAXCOMBLEN-1] = tjamo;
+ comblen = 2;
+ }