return 0 if no pair found */
| 789 | |
| 790 | /* return 0 if no pair found */ |
| 791 | static int unicode_compose_pair(uint32_t c0, uint32_t c1) |
| 792 | { |
| 793 | uint32_t code, len, type, v, idx1, d_idx, d_offset, ch; |
| 794 | int idx_min, idx_max, idx, d; |
| 795 | uint32_t pair[2]; |
| 796 | |
| 797 | idx_min = 0; |
| 798 | idx_max = countof(unicode_comp_table) - 1; |
| 799 | while (idx_min <= idx_max) { |
| 800 | idx = (idx_max + idx_min) / 2; |
| 801 | idx1 = unicode_comp_table[idx]; |
| 802 | |
| 803 | /* idx1 represent an entry of the decomposition table */ |
| 804 | d_idx = idx1 >> 6; |
| 805 | d_offset = idx1 & 0x3f; |
| 806 | v = unicode_decomp_table1[d_idx]; |
| 807 | code = v >> (32 - 18); |
| 808 | len = (v >> (32 - 18 - 7)) & 0x7f; |
| 809 | type = (v >> (32 - 18 - 7 - 6)) & 0x3f; |
| 810 | ch = code + d_offset; |
| 811 | unicode_decomp_entry(pair, ch, d_idx, code, len, type); |
| 812 | d = c0 - pair[0]; |
| 813 | if (d == 0) |
| 814 | d = c1 - pair[1]; |
| 815 | if (d < 0) { |
| 816 | idx_max = idx - 1; |
| 817 | } else if (d > 0) { |
| 818 | idx_min = idx + 1; |
| 819 | } else { |
| 820 | return ch; |
| 821 | } |
| 822 | } |
| 823 | return 0; |
| 824 | } |
| 825 | |
| 826 | /* return the combining class of character c (between 0 and 255) */ |
| 827 | static int unicode_get_cc(uint32_t c) |
no test coverage detected