This source file includes following definitions.
- uc_decomposition
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <config.h>
27
28
29 #include "uninorm.h"
30
31 #include "uninorm/decomposition-table.h"
32
33 int
34 uc_decomposition (ucs4_t uc, int *decomp_tag, ucs4_t *decomposition)
35 {
36 if (uc >= 0xAC00 && uc < 0xD7A4)
37 {
38
39
40
41
42 unsigned int t;
43
44 uc -= 0xAC00;
45 t = uc % 28;
46
47 *decomp_tag = UC_DECOMP_CANONICAL;
48 if (t == 0)
49 {
50 unsigned int v, l;
51
52 uc = uc / 28;
53 v = uc % 21;
54 l = uc / 21;
55
56 decomposition[0] = 0x1100 + l;
57 decomposition[1] = 0x1161 + v;
58 return 2;
59 }
60 else
61 {
62 #if 1
63 decomposition[0] = 0xAC00 + uc - t;
64 decomposition[1] = 0x11A7 + t;
65 return 2;
66 #else
67 unsigned int v, l;
68
69 uc = uc / 28;
70 v = uc % 21;
71 l = uc / 21;
72
73 decomposition[0] = 0x1100 + l;
74 decomposition[1] = 0x1161 + v;
75 decomposition[2] = 0x11A7 + t;
76 return 3;
77 #endif
78 }
79 }
80 else if (uc < 0x110000)
81 {
82 unsigned short entry = decomp_index (uc);
83 if (entry != (unsigned short)(-1))
84 {
85 const unsigned char *p;
86 unsigned int element;
87 unsigned int length;
88
89 p = &gl_uninorm_decomp_chars_table[3 * (entry & 0x7FFF)];
90 element = (p[0] << 16) | (p[1] << 8) | p[2];
91
92 *decomp_tag = (element >> 18) & 0x1f;
93 length = 1;
94 for (;;)
95 {
96
97 *decomposition = element & 0x3ffff;
98
99 if ((element & (1 << 23)) == 0)
100 break;
101 p += 3;
102 element = (p[0] << 16) | (p[1] << 8) | p[2];
103 decomposition++;
104 length++;
105 }
106 return length;
107 }
108 }
109 return -1;
110 }