3 * Copyright (c) 1998-2000, Larry Wall
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * 'What a fix!' said Sam. 'That's the one place in all the lands we've ever
12 * heard of that we don't want to see any closer; and that's the one place
13 * we're trying to get to! And that's just where we can't get, nohow.'
15 * 'Well do I understand your speech,' he answered in the same language;
16 * 'yet few strangers do so. Why then do you not speak in the Common Tongue,
17 * as is the custom in the West, if you wish to be answered?'
19 * ...the travellers perceived that the floor was paved with stones of many
20 * hues; branching runes and strange devices intertwined beneath their feet.
24 #define PERL_IN_UTF8_C
30 Perl_uv_to_utf8(pTHX_ U8 *d, UV uv)
37 *d++ = (( uv >> 6) | 0xc0);
38 *d++ = (( uv & 0x3f) | 0x80);
42 *d++ = (( uv >> 12) | 0xe0);
43 *d++ = (((uv >> 6) & 0x3f) | 0x80);
44 *d++ = (( uv & 0x3f) | 0x80);
48 *d++ = (( uv >> 18) | 0xf0);
49 *d++ = (((uv >> 12) & 0x3f) | 0x80);
50 *d++ = (((uv >> 6) & 0x3f) | 0x80);
51 *d++ = (( uv & 0x3f) | 0x80);
55 *d++ = (( uv >> 24) | 0xf8);
56 *d++ = (((uv >> 18) & 0x3f) | 0x80);
57 *d++ = (((uv >> 12) & 0x3f) | 0x80);
58 *d++ = (((uv >> 6) & 0x3f) | 0x80);
59 *d++ = (( uv & 0x3f) | 0x80);
62 if (uv < 0x80000000) {
63 *d++ = (( uv >> 30) | 0xfc);
64 *d++ = (((uv >> 24) & 0x3f) | 0x80);
65 *d++ = (((uv >> 18) & 0x3f) | 0x80);
66 *d++ = (((uv >> 12) & 0x3f) | 0x80);
67 *d++ = (((uv >> 6) & 0x3f) | 0x80);
68 *d++ = (( uv & 0x3f) | 0x80);
72 if (uv < 0x1000000000LL)
75 *d++ = 0xfe; /* Can't match U+FEFF! */
76 *d++ = (((uv >> 30) & 0x3f) | 0x80);
77 *d++ = (((uv >> 24) & 0x3f) | 0x80);
78 *d++ = (((uv >> 18) & 0x3f) | 0x80);
79 *d++ = (((uv >> 12) & 0x3f) | 0x80);
80 *d++ = (((uv >> 6) & 0x3f) | 0x80);
81 *d++ = (( uv & 0x3f) | 0x80);
86 *d++ = 0xff; /* Can't match U+FFFE! */
87 *d++ = 0x80; /* 6 Reserved bits */
88 *d++ = (((uv >> 60) & 0x0f) | 0x80); /* 2 Reserved bits */
89 *d++ = (((uv >> 54) & 0x3f) | 0x80);
90 *d++ = (((uv >> 48) & 0x3f) | 0x80);
91 *d++ = (((uv >> 42) & 0x3f) | 0x80);
92 *d++ = (((uv >> 36) & 0x3f) | 0x80);
93 *d++ = (((uv >> 30) & 0x3f) | 0x80);
94 *d++ = (((uv >> 24) & 0x3f) | 0x80);
95 *d++ = (((uv >> 18) & 0x3f) | 0x80);
96 *d++ = (((uv >> 12) & 0x3f) | 0x80);
97 *d++ = (((uv >> 6) & 0x3f) | 0x80);
98 *d++ = (( uv & 0x3f) | 0x80);
104 /* Tests if some arbitrary number of bytes begins in a valid UTF-8 character.
105 * The actual number of bytes in the UTF-8 character will be returned if it
106 * is valid, otherwise 0. */
108 Perl_is_utf8_char(pTHX_ U8 *s)
119 if (!(u & 0x20)) { len = 2; }
120 else if (!(u & 0x10)) { len = 3; }
121 else if (!(u & 0x08)) { len = 4; }
122 else if (!(u & 0x04)) { len = 5; }
123 else if (!(u & 0x02)) { len = 6; }
124 else if (!(u & 0x01)) { len = 7; }
125 else { len = 13; } /* whoa! */
130 if ((*s & 0xc0) != 0x80)
138 =for apidoc Am|bool_utf8_string|U8 *s|STRLEN len
140 Returns true if first C<len> bytes of the given string form valid a UTF8
141 string, false otherwise.
147 Perl_is_utf8_string(pTHX_ U8 *s, STRLEN len)
162 Perl_utf8_to_uv(pTHX_ U8* s, I32* retlen)
173 if (ckWARN_d(WARN_UTF8))
174 Perl_warner(aTHX_ WARN_UTF8, "Malformed UTF-8 character");
180 if (!(uv & 0x20)) { len = 2; uv &= 0x1f; }
181 else if (!(uv & 0x10)) { len = 3; uv &= 0x0f; }
182 else if (!(uv & 0x08)) { len = 4; uv &= 0x07; }
183 else if (!(uv & 0x04)) { len = 5; uv &= 0x03; }
184 else if (!(uv & 0x02)) { len = 6; uv &= 0x01; }
185 else if (!(uv & 0x01)) { len = 7; uv = 0; }
186 else { len = 13; uv = 0; } /* whoa! */
193 if ((*s & 0xc0) != 0x80) {
195 if (ckWARN_d(WARN_UTF8))
196 Perl_warner(aTHX_ WARN_UTF8, "Malformed UTF-8 character");
202 uv = (uv << 6) | (*s++ & 0x3f);
207 /* utf8_distance(a,b) is intended to be a - b in pointer arithmetic */
210 Perl_utf8_distance(pTHX_ U8 *a, U8 *b)
228 /* WARNING: do not use the following unless you *know* off is within bounds */
231 Perl_utf8_hop(pTHX_ U8 *s, I32 off)
241 while ((*s & 0xc0) == 0x80)
250 =for apidoc Am|U8 *|utf8_to_bytes|U8 *s|STRLEN len
252 Converts a string C<s> of length C<len> from UTF8 into ASCII encoding.
253 Unlike C<bytes_to_utf8>, this over-writes the original string.
254 Returns zero on failure after converting as much as possible.
260 Perl_utf8_to_bytes(pTHX_ U8* s, STRLEN len)
274 UV uv = utf8_to_uv(s, &ulen);
288 =for apidoc Am|U8 *|bytes_to_utf8|U8 *s|STRLEN *len
290 Converts a string C<s> of length C<len> from ASCII into UTF8 encoding.
291 Returns a pointer to the newly-created string, and sets C<len> to
292 reflect the new length.
298 Perl_bytes_to_utf8(pTHX_ U8* s, STRLEN *len)
306 Newz(801, d, (*len) * 2 + 1, U8);
314 *d++ = (( uv >> 6) | 0xc0);
315 *d++ = (( uv & 0x3f) | 0x80);
324 * Convert native (big-endian) or reversed (little-endian) UTF-16 to UTF-8.
326 * Destination must be pre-extended to 3/2 source. Do not use in-place.
327 * We optimize for native, for obvious reasons. */
330 Perl_utf16_to_utf8(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen)
336 Perl_croak(aTHX_ "panic: utf16_to_utf8: odd bytelen");
341 UV uv = (p[0] << 8) + p[1]; /* UTF-16BE */
348 *d++ = (( uv >> 6) | 0xc0);
349 *d++ = (( uv & 0x3f) | 0x80);
352 if (uv >= 0xd800 && uv < 0xdbff) { /* surrogates */
355 if (low < 0xdc00 || low >= 0xdfff)
356 Perl_croak(aTHX_ "Malformed UTF-16 surrogate");
357 uv = ((uv - 0xd800) << 10) + (low - 0xdc00) + 0x10000;
360 *d++ = (( uv >> 12) | 0xe0);
361 *d++ = (((uv >> 6) & 0x3f) | 0x80);
362 *d++ = (( uv & 0x3f) | 0x80);
366 *d++ = (( uv >> 18) | 0xf0);
367 *d++ = (((uv >> 12) & 0x3f) | 0x80);
368 *d++ = (((uv >> 6) & 0x3f) | 0x80);
369 *d++ = (( uv & 0x3f) | 0x80);
373 *newlen = d - dstart;
377 /* Note: this one is slightly destructive of the source. */
380 Perl_utf16_to_utf8_reversed(pTHX_ U8* p, U8* d, I32 bytelen, I32 *newlen)
383 U8* send = s + bytelen;
390 return utf16_to_utf8(p, d, bytelen, newlen);
393 /* for now these are all defined (inefficiently) in terms of the utf8 versions */
396 Perl_is_uni_alnum(pTHX_ U32 c)
398 U8 tmpbuf[UTF8_MAXLEN];
399 uv_to_utf8(tmpbuf, (UV)c);
400 return is_utf8_alnum(tmpbuf);
404 Perl_is_uni_alnumc(pTHX_ U32 c)
406 U8 tmpbuf[UTF8_MAXLEN];
407 uv_to_utf8(tmpbuf, (UV)c);
408 return is_utf8_alnumc(tmpbuf);
412 Perl_is_uni_idfirst(pTHX_ U32 c)
414 U8 tmpbuf[UTF8_MAXLEN];
415 uv_to_utf8(tmpbuf, (UV)c);
416 return is_utf8_idfirst(tmpbuf);
420 Perl_is_uni_alpha(pTHX_ U32 c)
422 U8 tmpbuf[UTF8_MAXLEN];
423 uv_to_utf8(tmpbuf, (UV)c);
424 return is_utf8_alpha(tmpbuf);
428 Perl_is_uni_ascii(pTHX_ U32 c)
430 U8 tmpbuf[UTF8_MAXLEN];
431 uv_to_utf8(tmpbuf, (UV)c);
432 return is_utf8_ascii(tmpbuf);
436 Perl_is_uni_space(pTHX_ U32 c)
438 U8 tmpbuf[UTF8_MAXLEN];
439 uv_to_utf8(tmpbuf, (UV)c);
440 return is_utf8_space(tmpbuf);
444 Perl_is_uni_digit(pTHX_ U32 c)
446 U8 tmpbuf[UTF8_MAXLEN];
447 uv_to_utf8(tmpbuf, (UV)c);
448 return is_utf8_digit(tmpbuf);
452 Perl_is_uni_upper(pTHX_ U32 c)
454 U8 tmpbuf[UTF8_MAXLEN];
455 uv_to_utf8(tmpbuf, (UV)c);
456 return is_utf8_upper(tmpbuf);
460 Perl_is_uni_lower(pTHX_ U32 c)
462 U8 tmpbuf[UTF8_MAXLEN];
463 uv_to_utf8(tmpbuf, (UV)c);
464 return is_utf8_lower(tmpbuf);
468 Perl_is_uni_cntrl(pTHX_ U32 c)
470 U8 tmpbuf[UTF8_MAXLEN];
471 uv_to_utf8(tmpbuf, (UV)c);
472 return is_utf8_cntrl(tmpbuf);
476 Perl_is_uni_graph(pTHX_ U32 c)
478 U8 tmpbuf[UTF8_MAXLEN];
479 uv_to_utf8(tmpbuf, (UV)c);
480 return is_utf8_graph(tmpbuf);
484 Perl_is_uni_print(pTHX_ U32 c)
486 U8 tmpbuf[UTF8_MAXLEN];
487 uv_to_utf8(tmpbuf, (UV)c);
488 return is_utf8_print(tmpbuf);
492 Perl_is_uni_punct(pTHX_ U32 c)
494 U8 tmpbuf[UTF8_MAXLEN];
495 uv_to_utf8(tmpbuf, (UV)c);
496 return is_utf8_punct(tmpbuf);
500 Perl_is_uni_xdigit(pTHX_ U32 c)
502 U8 tmpbuf[UTF8_MAXLEN];
503 uv_to_utf8(tmpbuf, (UV)c);
504 return is_utf8_xdigit(tmpbuf);
508 Perl_to_uni_upper(pTHX_ U32 c)
510 U8 tmpbuf[UTF8_MAXLEN];
511 uv_to_utf8(tmpbuf, (UV)c);
512 return to_utf8_upper(tmpbuf);
516 Perl_to_uni_title(pTHX_ U32 c)
518 U8 tmpbuf[UTF8_MAXLEN];
519 uv_to_utf8(tmpbuf, (UV)c);
520 return to_utf8_title(tmpbuf);
524 Perl_to_uni_lower(pTHX_ U32 c)
526 U8 tmpbuf[UTF8_MAXLEN];
527 uv_to_utf8(tmpbuf, (UV)c);
528 return to_utf8_lower(tmpbuf);
531 /* for now these all assume no locale info available for Unicode > 255 */
534 Perl_is_uni_alnum_lc(pTHX_ U32 c)
536 return is_uni_alnum(c); /* XXX no locale support yet */
540 Perl_is_uni_alnumc_lc(pTHX_ U32 c)
542 return is_uni_alnumc(c); /* XXX no locale support yet */
546 Perl_is_uni_idfirst_lc(pTHX_ U32 c)
548 return is_uni_idfirst(c); /* XXX no locale support yet */
552 Perl_is_uni_alpha_lc(pTHX_ U32 c)
554 return is_uni_alpha(c); /* XXX no locale support yet */
558 Perl_is_uni_ascii_lc(pTHX_ U32 c)
560 return is_uni_ascii(c); /* XXX no locale support yet */
564 Perl_is_uni_space_lc(pTHX_ U32 c)
566 return is_uni_space(c); /* XXX no locale support yet */
570 Perl_is_uni_digit_lc(pTHX_ U32 c)
572 return is_uni_digit(c); /* XXX no locale support yet */
576 Perl_is_uni_upper_lc(pTHX_ U32 c)
578 return is_uni_upper(c); /* XXX no locale support yet */
582 Perl_is_uni_lower_lc(pTHX_ U32 c)
584 return is_uni_lower(c); /* XXX no locale support yet */
588 Perl_is_uni_cntrl_lc(pTHX_ U32 c)
590 return is_uni_cntrl(c); /* XXX no locale support yet */
594 Perl_is_uni_graph_lc(pTHX_ U32 c)
596 return is_uni_graph(c); /* XXX no locale support yet */
600 Perl_is_uni_print_lc(pTHX_ U32 c)
602 return is_uni_print(c); /* XXX no locale support yet */
606 Perl_is_uni_punct_lc(pTHX_ U32 c)
608 return is_uni_punct(c); /* XXX no locale support yet */
612 Perl_is_uni_xdigit_lc(pTHX_ U32 c)
614 return is_uni_xdigit(c); /* XXX no locale support yet */
618 Perl_to_uni_upper_lc(pTHX_ U32 c)
620 return to_uni_upper(c); /* XXX no locale support yet */
624 Perl_to_uni_title_lc(pTHX_ U32 c)
626 return to_uni_title(c); /* XXX no locale support yet */
630 Perl_to_uni_lower_lc(pTHX_ U32 c)
632 return to_uni_lower(c); /* XXX no locale support yet */
636 Perl_is_utf8_alnum(pTHX_ U8 *p)
638 if (!is_utf8_char(p))
641 PL_utf8_alnum = swash_init("utf8", "IsAlnum", &PL_sv_undef, 0, 0);
642 return swash_fetch(PL_utf8_alnum, p);
643 /* return *p == '_' || is_utf8_alpha(p) || is_utf8_digit(p); */
644 #ifdef SURPRISINGLY_SLOWER /* probably because alpha is usually true */
646 PL_utf8_alnum = swash_init("utf8", "",
647 sv_2mortal(newSVpv("+utf8::IsAlpha\n+utf8::IsDigit\n005F\n",0)), 0, 0);
648 return swash_fetch(PL_utf8_alnum, p);
653 Perl_is_utf8_alnumc(pTHX_ U8 *p)
655 if (!is_utf8_char(p))
658 PL_utf8_alnum = swash_init("utf8", "IsAlnumC", &PL_sv_undef, 0, 0);
659 return swash_fetch(PL_utf8_alnum, p);
660 /* return is_utf8_alpha(p) || is_utf8_digit(p); */
661 #ifdef SURPRISINGLY_SLOWER /* probably because alpha is usually true */
663 PL_utf8_alnum = swash_init("utf8", "",
664 sv_2mortal(newSVpv("+utf8::IsAlpha\n+utf8::IsDigit\n005F\n",0)), 0, 0);
665 return swash_fetch(PL_utf8_alnum, p);
670 Perl_is_utf8_idfirst(pTHX_ U8 *p)
672 return *p == '_' || is_utf8_alpha(p);
676 Perl_is_utf8_alpha(pTHX_ U8 *p)
678 if (!is_utf8_char(p))
681 PL_utf8_alpha = swash_init("utf8", "IsAlpha", &PL_sv_undef, 0, 0);
682 return swash_fetch(PL_utf8_alpha, p);
686 Perl_is_utf8_ascii(pTHX_ U8 *p)
688 if (!is_utf8_char(p))
691 PL_utf8_ascii = swash_init("utf8", "IsAscii", &PL_sv_undef, 0, 0);
692 return swash_fetch(PL_utf8_ascii, p);
696 Perl_is_utf8_space(pTHX_ U8 *p)
698 if (!is_utf8_char(p))
701 PL_utf8_space = swash_init("utf8", "IsSpace", &PL_sv_undef, 0, 0);
702 return swash_fetch(PL_utf8_space, p);
706 Perl_is_utf8_digit(pTHX_ U8 *p)
708 if (!is_utf8_char(p))
711 PL_utf8_digit = swash_init("utf8", "IsDigit", &PL_sv_undef, 0, 0);
712 return swash_fetch(PL_utf8_digit, p);
716 Perl_is_utf8_upper(pTHX_ U8 *p)
718 if (!is_utf8_char(p))
721 PL_utf8_upper = swash_init("utf8", "IsUpper", &PL_sv_undef, 0, 0);
722 return swash_fetch(PL_utf8_upper, p);
726 Perl_is_utf8_lower(pTHX_ U8 *p)
728 if (!is_utf8_char(p))
731 PL_utf8_lower = swash_init("utf8", "IsLower", &PL_sv_undef, 0, 0);
732 return swash_fetch(PL_utf8_lower, p);
736 Perl_is_utf8_cntrl(pTHX_ U8 *p)
738 if (!is_utf8_char(p))
741 PL_utf8_cntrl = swash_init("utf8", "IsCntrl", &PL_sv_undef, 0, 0);
742 return swash_fetch(PL_utf8_cntrl, p);
746 Perl_is_utf8_graph(pTHX_ U8 *p)
748 if (!is_utf8_char(p))
751 PL_utf8_graph = swash_init("utf8", "IsGraph", &PL_sv_undef, 0, 0);
752 return swash_fetch(PL_utf8_graph, p);
756 Perl_is_utf8_print(pTHX_ U8 *p)
758 if (!is_utf8_char(p))
761 PL_utf8_print = swash_init("utf8", "IsPrint", &PL_sv_undef, 0, 0);
762 return swash_fetch(PL_utf8_print, p);
766 Perl_is_utf8_punct(pTHX_ U8 *p)
768 if (!is_utf8_char(p))
771 PL_utf8_punct = swash_init("utf8", "IsPunct", &PL_sv_undef, 0, 0);
772 return swash_fetch(PL_utf8_punct, p);
776 Perl_is_utf8_xdigit(pTHX_ U8 *p)
778 if (!is_utf8_char(p))
781 PL_utf8_xdigit = swash_init("utf8", "IsXDigit", &PL_sv_undef, 0, 0);
782 return swash_fetch(PL_utf8_xdigit, p);
786 Perl_is_utf8_mark(pTHX_ U8 *p)
788 if (!is_utf8_char(p))
791 PL_utf8_mark = swash_init("utf8", "IsM", &PL_sv_undef, 0, 0);
792 return swash_fetch(PL_utf8_mark, p);
796 Perl_to_utf8_upper(pTHX_ U8 *p)
800 if (!PL_utf8_toupper)
801 PL_utf8_toupper = swash_init("utf8", "ToUpper", &PL_sv_undef, 4, 0);
802 uv = swash_fetch(PL_utf8_toupper, p);
803 return uv ? uv : utf8_to_uv(p,0);
807 Perl_to_utf8_title(pTHX_ U8 *p)
811 if (!PL_utf8_totitle)
812 PL_utf8_totitle = swash_init("utf8", "ToTitle", &PL_sv_undef, 4, 0);
813 uv = swash_fetch(PL_utf8_totitle, p);
814 return uv ? uv : utf8_to_uv(p,0);
818 Perl_to_utf8_lower(pTHX_ U8 *p)
822 if (!PL_utf8_tolower)
823 PL_utf8_tolower = swash_init("utf8", "ToLower", &PL_sv_undef, 4, 0);
824 uv = swash_fetch(PL_utf8_tolower, p);
825 return uv ? uv : utf8_to_uv(p,0);
828 /* a "swash" is a swatch hash */
831 Perl_swash_init(pTHX_ char* pkg, char* name, SV *listsv, I32 minbits, I32 none)
837 if (!gv_stashpv(pkg, 0)) { /* demand load utf8 */
839 Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpv(pkg,0), Nullsv);
843 PUSHSTACKi(PERLSI_MAGIC);
846 PUSHs(sv_2mortal(newSVpvn(pkg, strlen(pkg))));
847 PUSHs(sv_2mortal(newSVpvn(name, strlen(name))));
849 PUSHs(sv_2mortal(newSViv(minbits)));
850 PUSHs(sv_2mortal(newSViv(none)));
856 if (PL_curcop == &PL_compiling) /* XXX ought to be handled by lex_start */
857 strncpy(tmpbuf, PL_tokenbuf, sizeof tmpbuf);
858 if (call_method("SWASHNEW", G_SCALAR))
859 retval = newSVsv(*PL_stack_sp--);
861 retval = &PL_sv_undef;
864 if (PL_curcop == &PL_compiling) {
865 strncpy(PL_tokenbuf, tmpbuf, sizeof tmpbuf);
866 PL_curcop->op_private = PL_hints;
868 if (!SvROK(retval) || SvTYPE(SvRV(retval)) != SVt_PVHV)
869 Perl_croak(aTHX_ "SWASHNEW didn't return an HV ref");
874 Perl_swash_fetch(pTHX_ SV *sv, U8 *ptr)
876 HV* hv = (HV*)SvRV(sv);
877 U32 klen = UTF8SKIP(ptr) - 1;
878 U32 off = ptr[klen] & 127; /* NB: 64 bit always 0 when len > 1 */
880 STRLEN needents = (klen ? 64 : 128);
886 * This single-entry cache saves about 1/3 of the utf8 overhead in test
887 * suite. (That is, only 7-8% overall over just a hash cache. Still,
888 * it's nothing to sniff at.) Pity we usually come through at least
889 * two function calls to get here...
891 * NB: this code assumes that swatches are never modified, once generated!
894 if (hv == PL_last_swash_hv &&
895 klen == PL_last_swash_klen &&
896 (!klen || memEQ((char *)ptr,(char *)PL_last_swash_key,klen)) )
898 tmps = PL_last_swash_tmps;
899 slen = PL_last_swash_slen;
902 /* Try our second-level swatch cache, kept in a hash. */
903 SV** svp = hv_fetch(hv, (char*)ptr, klen, FALSE);
905 /* If not cached, generate it via utf8::SWASHGET */
906 if (!svp || !SvPOK(*svp) || !(tmps = (U8*)SvPV(*svp, slen))) {
911 PUSHSTACKi(PERLSI_MAGIC);
915 PUSHs(sv_2mortal(newSViv(utf8_to_uv(ptr, 0) & ~(needents - 1))));
916 PUSHs(sv_2mortal(newSViv(needents)));
918 if (call_method("SWASHGET", G_SCALAR))
919 retval = newSVsv(*PL_stack_sp--);
921 retval = &PL_sv_undef;
925 if (PL_curcop == &PL_compiling)
926 PL_curcop->op_private = PL_hints;
928 svp = hv_store(hv, (char*)ptr, klen, retval, 0);
930 if (!svp || !(tmps = (U8*)SvPV(*svp, slen)) || slen < 8)
931 Perl_croak(aTHX_ "SWASHGET didn't return result of proper length");
934 PL_last_swash_hv = hv;
935 PL_last_swash_klen = klen;
936 PL_last_swash_tmps = tmps;
937 PL_last_swash_slen = slen;
939 Copy(ptr, PL_last_swash_key, klen, U8);
942 switch ((slen << 3) / needents) {
944 bit = 1 << (off & 7);
946 return (tmps[off] & bit) != 0;
951 return (tmps[off] << 8) + tmps[off + 1] ;
954 return (tmps[off] << 24) + (tmps[off+1] << 16) + (tmps[off+2] << 8) + tmps[off + 3] ;
956 Perl_croak(aTHX_ "panic: swash_fetch");