X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Funinorm%2Fcanonical-decomposition.c;h=210b74b9cac74fcfb2a9635e65eb5f3096f808ef;hb=ba4000b09804294e46373afb2003744612096a20;hp=9afaead0aeb6377b163bec7eb13bc9905aa1eb13;hpb=fc94d226b18f8f89f105c5212ef8e5a297ce9412;p=gnulib.git diff --git a/lib/uninorm/canonical-decomposition.c b/lib/uninorm/canonical-decomposition.c index 9afaead0a..210b74b9c 100644 --- a/lib/uninorm/canonical-decomposition.c +++ b/lib/uninorm/canonical-decomposition.c @@ -29,24 +29,45 @@ uc_canonical_decomposition (ucs4_t uc, ucs4_t *decomposition) { if (uc >= 0xAC00 && uc < 0xD7A4) { - /* Hangul syllable. See Unicode standard, chapter 3, - section "Hangul Syllable Decomposition". */ - unsigned int t, v, l; + /* Hangul syllable. See Unicode standard, chapter 3, section + "Hangul Syllable Decomposition", See also the clarification at + , section + "Clarification of Hangul Jamo Handling". */ + unsigned int t; uc -= 0xAC00; t = uc % 28; - uc = uc / 28; - v = uc % 21; - l = uc / 21; - decomposition[0] = 0x1100 + l; - decomposition[1] = 0x1161 + v; if (t == 0) - return 2; + { + unsigned int v, l; + + uc = uc / 28; + v = uc % 21; + l = uc / 21; + + decomposition[0] = 0x1100 + l; + decomposition[1] = 0x1161 + v; + return 2; + } else { +#if 1 /* Return the pairwise decomposition, not the full decomposition. */ + decomposition[0] = 0xAC00 + uc - t; /* = 0xAC00 + (l * 21 + v) * 28; */ + decomposition[1] = 0x11A7 + t; + return 2; +#else + unsigned int v, l; + + uc = uc / 28; + v = uc % 21; + l = uc / 21; + + decomposition[0] = 0x1100 + l; + decomposition[1] = 0x1161 + v; decomposition[2] = 0x11A7 + t; return 3; +#endif } } else if (uc < 0x110000)