MCPcopy Create free account
hub / github.com/buke/quickjs-go / unicode_decomp_entry

Function unicode_decomp_entry

deps/quickjs/libunicode.c:621–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619}
620
621static int unicode_decomp_entry(uint32_t *res, uint32_t c,
622 int idx, uint32_t code, uint32_t len,
623 uint32_t type)
624{
625 uint32_t c1;
626 int l, i, p;
627 const uint8_t *d;
628
629 if (type == DECOMP_TYPE_C1) {
630 res[0] = unicode_decomp_table2[idx];
631 return 1;
632 } else {
633 d = unicode_decomp_data + unicode_decomp_table2[idx];
634 switch(type) {
635 case DECOMP_TYPE_L1:
636 case DECOMP_TYPE_L2:
637 case DECOMP_TYPE_L3:
638 case DECOMP_TYPE_L4:
639 case DECOMP_TYPE_L5:
640 case DECOMP_TYPE_L6:
641 case DECOMP_TYPE_L7:
642 l = type - DECOMP_TYPE_L1 + 1;
643 d += (c - code) * l * 2;
644 for(i = 0; i < l; i++) {
645 if ((res[i] = unicode_get16(d + 2 * i)) == 0)
646 return 0;
647 }
648 return l;
649 case DECOMP_TYPE_LL1:
650 case DECOMP_TYPE_LL2:
651 {
652 uint32_t k, p;
653 l = type - DECOMP_TYPE_LL1 + 1;
654 k = (c - code) * l;
655 p = len * l * 2;
656 for(i = 0; i < l; i++) {
657 c1 = unicode_get16(d + 2 * k) |
658 (((d[p + (k / 4)] >> ((k % 4) * 2)) & 3) << 16);
659 if (!c1)
660 return 0;
661 res[i] = c1;
662 k++;
663 }
664 }
665 return l;
666 case DECOMP_TYPE_S1:
667 case DECOMP_TYPE_S2:
668 case DECOMP_TYPE_S3:
669 case DECOMP_TYPE_S4:
670 case DECOMP_TYPE_S5:
671 l = type - DECOMP_TYPE_S1 + 1;
672 d += (c - code) * l;
673 for(i = 0; i < l; i++) {
674 if ((res[i] = unicode_get_short_code(d[i])) == 0)
675 return 0;
676 }
677 return l;
678 case DECOMP_TYPE_I1:

Callers 2

unicode_decomp_charFunction · 0.85
unicode_compose_pairFunction · 0.85

Calls 3

unicode_get16Function · 0.85
unicode_get_short_codeFunction · 0.85
unicode_get_lower_simpleFunction · 0.85

Tested by

no test coverage detected