* The combining_class() function checks on the given bytes and find out * the corresponding Unicode combining class value. The return value 0 means * it is a Starter. Any illegal UTF-8 character will also be treated as * a Starter. */
| 686 | * a Starter. |
| 687 | */ |
| 688 | static uchar_t |
| 689 | combining_class(size_t uv, uchar_t *s, size_t sz) |
| 690 | { |
| 691 | uint16_t b1 = 0; |
| 692 | uint16_t b2 = 0; |
| 693 | uint16_t b3 = 0; |
| 694 | uint16_t b4 = 0; |
| 695 | |
| 696 | if (sz == 1 || sz > 4) |
| 697 | return (0); |
| 698 | |
| 699 | if (sz == 2) { |
| 700 | b3 = s[0]; |
| 701 | b4 = s[1]; |
| 702 | } else if (sz == 3) { |
| 703 | b2 = s[0]; |
| 704 | b3 = s[1]; |
| 705 | b4 = s[2]; |
| 706 | } else if (sz == 4) { |
| 707 | b1 = s[0]; |
| 708 | b2 = s[1]; |
| 709 | b3 = s[2]; |
| 710 | b4 = s[3]; |
| 711 | } |
| 712 | |
| 713 | b1 = u8_common_b1_tbl[uv][b1]; |
| 714 | if (b1 == U8_TBL_ELEMENT_NOT_DEF) |
| 715 | return (0); |
| 716 | |
| 717 | b2 = u8_combining_class_b2_tbl[uv][b1][b2]; |
| 718 | if (b2 == U8_TBL_ELEMENT_NOT_DEF) |
| 719 | return (0); |
| 720 | |
| 721 | b3 = u8_combining_class_b3_tbl[uv][b2][b3]; |
| 722 | if (b3 == U8_TBL_ELEMENT_NOT_DEF) |
| 723 | return (0); |
| 724 | |
| 725 | return (u8_combining_class_b4_tbl[uv][b3][b4]); |
| 726 | } |
| 727 | |
| 728 | /* |
| 729 | * The do_decomp() function finds out a matching decomposition if any |