|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <config.h> |
|
|
|
|
|
|
|
|
#include "uninorm.h" |
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
struct composition_rule { char codes[6] _GL_ATTRIBUTE_NONSTRING; unsigned int combined; }; |
|
|
|
|
|
#include "composition-table.h" |
|
|
#include "composition-table-bounds.h" |
|
|
|
|
|
ucs4_t |
|
|
uc_composition (ucs4_t uc1, ucs4_t uc2) |
|
|
{ |
|
|
if (uc1 <= UNINORM_COMPOSE_MAX_ARG1 && uc2 <= UNINORM_COMPOSE_MAX_ARG2) |
|
|
{ |
|
|
if (uc2 >= 0x1161 && uc2 < 0x1161 + 21 |
|
|
&& uc1 >= 0x1100 && uc1 < 0x1100 + 19) |
|
|
{ |
|
|
|
|
|
|
|
|
return 0xAC00 + ((uc1 - 0x1100) * 21 + (uc2 - 0x1161)) * 28; |
|
|
} |
|
|
else if (uc2 > 0x11A7 && uc2 < 0x11A7 + 28 |
|
|
&& uc1 >= 0xAC00 && uc1 < 0xD7A4 && ((uc1 - 0xAC00) % 28) == 0) |
|
|
{ |
|
|
|
|
|
|
|
|
return uc1 + (uc2 - 0x11A7); |
|
|
} |
|
|
else |
|
|
{ |
|
|
#if 0 |
|
|
unsigned int uc = MUL1 * uc1 * MUL2 * uc2; |
|
|
unsigned int index1 = uc >> composition_header_0; |
|
|
if (index1 < composition_header_1) |
|
|
{ |
|
|
int lookup1 = u_composition.level1[index1]; |
|
|
if (lookup1 >= 0) |
|
|
{ |
|
|
unsigned int index2 = (uc >> composition_header_2) & composition_header_3; |
|
|
int lookup2 = u_composition.level2[lookup1 + index2]; |
|
|
if (lookup2 >= 0) |
|
|
{ |
|
|
unsigned int index3 = (uc & composition_header_4); |
|
|
unsigned int lookup3 = u_composition.level3[lookup2 + index3]; |
|
|
if ((lookup3 >> 16) == uc2) |
|
|
return lookup3 & ((1U << 16) - 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
#else |
|
|
char codes[6]; |
|
|
const struct composition_rule *rule; |
|
|
|
|
|
codes[0] = (uc1 >> 16) & 0xff; |
|
|
codes[1] = (uc1 >> 8) & 0xff; |
|
|
codes[2] = uc1 & 0xff; |
|
|
codes[3] = (uc2 >> 16) & 0xff; |
|
|
codes[4] = (uc2 >> 8) & 0xff; |
|
|
codes[5] = uc2 & 0xff; |
|
|
|
|
|
rule = gl_uninorm_compose_lookup (codes, 6); |
|
|
if (rule != NULL) |
|
|
return rule->combined; |
|
|
#endif |
|
|
} |
|
|
} |
|
|
return 0; |
|
|
} |
|
|
|