• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:diff

6 *   Copyright (C) 2002-2016, International Business Machines
11 * encoding: US-ASCII
19 * in its MIME-friendly form as defined in http://www.unicode.org/notes/tn6/
34 /* BOCU-1 constants and macros ---------------------------------------------- */
37 * BOCU-1 encodes the code points of a Unicode string as
38 * a sequence of byte-encoded differences (slope detection),
41 * Optimize the difference-taking for runs of Unicode text within
44 * Most small scripts are allocated within aligned 128-blocks of Unicode
51 * C0 control codes and space are encoded with their US-ASCII bytes.
66 #define BOCU1_COUNT (BOCU1_MAX_LEAD-BOCU1_MIN+1)
70 #define BOCU1_TRAIL_BYTE_OFFSET (BOCU1_MIN-BOCU1_TRAIL_CONTROLS_COUNT)
73 #define BOCU1_TRAIL_COUNT ((BOCU1_MAX_TRAIL-BOCU1_MIN+1)+BOCU1_TRAIL_CONTROLS_COUNT)
76 * number of positive and negative single-byte codes
81 /* number of lead bytes for positive and negative 2/3/4-byte sequences */
86 /* The difference value range for single-byters. */
87 #define BOCU1_REACH_POS_1 (BOCU1_SINGLE-1)
88 #define BOCU1_REACH_NEG_1 (-BOCU1_SINGLE)
90 /* The difference value range for double-byters. */
92 #define BOCU1_REACH_NEG_2 (BOCU1_REACH_NEG_1-BOCU1_LEAD_2*BOCU1_TRAIL_COUNT)
94 /* The difference value range for 3-byters. */
98 #define BOCU1_REACH_NEG_3 (BOCU1_REACH_NEG_2-BOCU1_LEAD_3*BOCU1_TRAIL_COUNT*BOCU1_TRAIL_COUNT)
107 #define BOCU1_START_NEG_3 (BOCU1_START_NEG_2-BOCU1_LEAD_2)
108 #define BOCU1_START_NEG_4 (BOCU1_START_NEG_3-BOCU1_LEAD_3)
124 * which makes BOCU-1 MIME-usable and reasonably safe for
125 * ASCII-oriented software.
155 * External byte values that are illegal as trail bytes are mapped to -1.
160 -1, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, -1,
163 -1, -1, -1, -1, -1, -1, -1, -1,
169 0x0e, 0x0f, -1, -1, 0x10, 0x11, 0x12, 0x13,
172 -1
196 * This macro adjust the results so that the modulo-value m is always >=0.
209 --(n); \
214 /* Faster versions of packDiff() for single-byte-encoded diff values. */
216 /** Is a diff value encodable in a single byte? */
217 #define DIFF_IS_SINGLE(diff) (BOCU1_REACH_NEG_1<=(diff) && (diff)<=BOCU1_REACH_POS_1) argument
219 /** Encode a diff value in a single byte. */
220 #define PACK_SINGLE_DIFF(diff) (BOCU1_MIDDLE+(diff)) argument
222 /** Is a diff value encodable in two bytes? */
223 #define DIFF_IS_DOUBLE(diff) (BOCU1_REACH_NEG_2<=(diff) && (diff)<=BOCU1_REACH_POS_2) argument
225 /* BOCU-1 implementation functions ------------------------------------------ */
240 /* Hiragana is not 128-aligned */ in bocu1Prev()
244 return 0x4e00-BOCU1_REACH_NEG_2; in bocu1Prev()
258 * The BOCU-1 converter uses the standard setup code in ucnv.c/ucnv_bld.c.
264 * mode decoder's incomplete (diff<<2)|count (ignored when toULength==0)
267 /* BOCU-1-from-Unicode conversion functions --------------------------------- */
270 * Encode a difference -0x10ffff..0x10ffff in 1..4 bytes
274 * to compress runs of same-script characters.
276 * Optimized version with unrolled loops and fewer floating-point operations
279 * @param diff difference value -0x10ffff..0x10ffff
281 * 0x010000zz for 1-byte sequence zz
282 * 0x0200yyzz for 2-byte sequence yy zz
283 * 0x03xxyyzz for 3-byte sequence xx yy zz
284 * 0xwwxxyyzz for 4-byte sequence ww xx yy zz (ww>0x03)
287 packDiff(int32_t diff) { in packDiff() argument
290 … U_ASSERT(!DIFF_IS_SINGLE(diff)); /* assume we won't be called where diff==BOCU1_REACH_NEG_1=-64 */ in packDiff()
291 if(diff>=BOCU1_REACH_NEG_1) { in packDiff()
292 /* mostly positive differences, and single-byte negative ones */ in packDiff()
293 #if 0 /* single-byte case handled in macros, see below */ in packDiff()
294 if(diff<=BOCU1_REACH_POS_1) { in packDiff()
296 return 0x01000000|(BOCU1_MIDDLE+diff); in packDiff()
299 if(diff<=BOCU1_REACH_POS_2) { in packDiff()
301 diff-=BOCU1_REACH_POS_1+1; in packDiff()
304 m=diff%BOCU1_TRAIL_COUNT; in packDiff()
305 diff/=BOCU1_TRAIL_COUNT; in packDiff()
308 result|=(BOCU1_START_POS_2+diff)<<8; in packDiff()
309 } else if(diff<=BOCU1_REACH_POS_3) { in packDiff()
311 diff-=BOCU1_REACH_POS_2+1; in packDiff()
314 m=diff%BOCU1_TRAIL_COUNT; in packDiff()
315 diff/=BOCU1_TRAIL_COUNT; in packDiff()
318 m=diff%BOCU1_TRAIL_COUNT; in packDiff()
319 diff/=BOCU1_TRAIL_COUNT; in packDiff()
322 result|=(BOCU1_START_POS_3+diff)<<16; in packDiff()
325 diff-=BOCU1_REACH_POS_3+1; in packDiff()
327 m=diff%BOCU1_TRAIL_COUNT; in packDiff()
328 diff/=BOCU1_TRAIL_COUNT; in packDiff()
331 m=diff%BOCU1_TRAIL_COUNT; in packDiff()
332 diff/=BOCU1_TRAIL_COUNT; in packDiff()
336 * We know that / and % would deliver quotient 0 and rest=diff. in packDiff()
339 result|=BOCU1_TRAIL_TO_BYTE(diff)<<16; in packDiff()
344 /* two- to four-byte negative differences */ in packDiff()
345 if(diff>=BOCU1_REACH_NEG_2) { in packDiff()
347 diff-=BOCU1_REACH_NEG_1; in packDiff()
350 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in packDiff()
353 result|=(BOCU1_START_NEG_2+diff)<<8; in packDiff()
354 } else if(diff>=BOCU1_REACH_NEG_3) { in packDiff()
356 diff-=BOCU1_REACH_NEG_2; in packDiff()
359 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in packDiff()
362 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in packDiff()
365 result|=(BOCU1_START_NEG_3+diff)<<16; in packDiff()
368 diff-=BOCU1_REACH_NEG_3; in packDiff()
370 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in packDiff()
373 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in packDiff()
378 * quotient -1 and rest=diff+BOCU1_TRAIL_COUNT. in packDiff()
381 m=diff+BOCU1_TRAIL_COUNT; in packDiff()
400 int32_t prev, c, diff; in _Bocu1FromUnicodeWithOffsets() local
405 cnv=pArgs->converter; in _Bocu1FromUnicodeWithOffsets()
406 source=pArgs->source; in _Bocu1FromUnicodeWithOffsets()
407 sourceLimit=pArgs->sourceLimit; in _Bocu1FromUnicodeWithOffsets()
408 target=(uint8_t *)pArgs->target; in _Bocu1FromUnicodeWithOffsets()
409 targetCapacity=(int32_t)(pArgs->targetLimit-pArgs->target); in _Bocu1FromUnicodeWithOffsets()
410 offsets=pArgs->offsets; in _Bocu1FromUnicodeWithOffsets()
413 c=cnv->fromUChar32; in _Bocu1FromUnicodeWithOffsets()
414 prev=(int32_t)cnv->fromUnicodeStatus; in _Bocu1FromUnicodeWithOffsets()
419 /* sourceIndex=-1 if the current character began in the previous buffer */ in _Bocu1FromUnicodeWithOffsets()
420 sourceIndex= c==0 ? 0 : -1; in _Bocu1FromUnicodeWithOffsets()
429 /* fast loop for single-byte differences */ in _Bocu1FromUnicodeWithOffsets()
431 diff=(int32_t)(sourceLimit-source); in _Bocu1FromUnicodeWithOffsets()
432 if(targetCapacity>diff) { in _Bocu1FromUnicodeWithOffsets()
433 targetCapacity=diff; in _Bocu1FromUnicodeWithOffsets()
443 --targetCapacity; in _Bocu1FromUnicodeWithOffsets()
445 diff=c-prev; in _Bocu1FromUnicodeWithOffsets()
446 if(DIFF_IS_SINGLE(diff)) { in _Bocu1FromUnicodeWithOffsets()
448 *target++=(uint8_t)PACK_SINGLE_DIFF(diff); in _Bocu1FromUnicodeWithOffsets()
451 --targetCapacity; in _Bocu1FromUnicodeWithOffsets()
458 targetCapacity=(int32_t)((const uint8_t *)pArgs->targetLimit-target); in _Bocu1FromUnicodeWithOffsets()
478 --targetCapacity; in _Bocu1FromUnicodeWithOffsets()
496 … c=-c; /* negative lead surrogate as "incomplete" indicator to avoid c=0 everywhere else */ in _Bocu1FromUnicodeWithOffsets()
503 * are encoded with the difference c-prev in _Bocu1FromUnicodeWithOffsets()
506 * placed in the middle of a 0x80-block (for most small scripts) or in _Bocu1FromUnicodeWithOffsets()
510 diff=c-prev; in _Bocu1FromUnicodeWithOffsets()
512 if(DIFF_IS_SINGLE(diff)) { in _Bocu1FromUnicodeWithOffsets()
513 *target++=(uint8_t)PACK_SINGLE_DIFF(diff); in _Bocu1FromUnicodeWithOffsets()
515 --targetCapacity; in _Bocu1FromUnicodeWithOffsets()
520 } else if(DIFF_IS_DOUBLE(diff) && 2<=targetCapacity) { in _Bocu1FromUnicodeWithOffsets()
521 /* optimize 2-byte case */ in _Bocu1FromUnicodeWithOffsets()
524 if(diff>=0) { in _Bocu1FromUnicodeWithOffsets()
525 diff-=BOCU1_REACH_POS_1+1; in _Bocu1FromUnicodeWithOffsets()
526 m=diff%BOCU1_TRAIL_COUNT; in _Bocu1FromUnicodeWithOffsets()
527 diff/=BOCU1_TRAIL_COUNT; in _Bocu1FromUnicodeWithOffsets()
528 diff+=BOCU1_START_POS_2; in _Bocu1FromUnicodeWithOffsets()
530 diff-=BOCU1_REACH_NEG_1; in _Bocu1FromUnicodeWithOffsets()
531 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in _Bocu1FromUnicodeWithOffsets()
532 diff+=BOCU1_START_NEG_2; in _Bocu1FromUnicodeWithOffsets()
534 *target++=(uint8_t)diff; in _Bocu1FromUnicodeWithOffsets()
538 targetCapacity-=2; in _Bocu1FromUnicodeWithOffsets()
543 diff=packDiff(diff); in _Bocu1FromUnicodeWithOffsets()
544 length=BOCU1_LENGTH_FROM_PACKED(diff); in _Bocu1FromUnicodeWithOffsets()
546 /* write the output character bytes from diff and length */ in _Bocu1FromUnicodeWithOffsets()
552 *target++=(uint8_t)(diff>>24); in _Bocu1FromUnicodeWithOffsets()
556 *target++=(uint8_t)(diff>>16); in _Bocu1FromUnicodeWithOffsets()
560 *target++=(uint8_t)(diff>>8); in _Bocu1FromUnicodeWithOffsets()
563 *target++=(uint8_t)diff; in _Bocu1FromUnicodeWithOffsets()
570 targetCapacity-=length; in _Bocu1FromUnicodeWithOffsets()
582 length-=targetCapacity; in _Bocu1FromUnicodeWithOffsets()
583 charErrorBuffer=(uint8_t *)cnv->charErrorBuffer; in _Bocu1FromUnicodeWithOffsets()
587 *charErrorBuffer++=(uint8_t)(diff>>16); in _Bocu1FromUnicodeWithOffsets()
590 *charErrorBuffer++=(uint8_t)(diff>>8); in _Bocu1FromUnicodeWithOffsets()
593 *charErrorBuffer=(uint8_t)diff; in _Bocu1FromUnicodeWithOffsets()
599 cnv->charErrorBufferLength=(int8_t)length; in _Bocu1FromUnicodeWithOffsets()
602 diff>>=8*length; /* length was reduced by targetCapacity */ in _Bocu1FromUnicodeWithOffsets()
606 *target++=(uint8_t)(diff>>16); in _Bocu1FromUnicodeWithOffsets()
610 *target++=(uint8_t)(diff>>8); in _Bocu1FromUnicodeWithOffsets()
614 *target++=(uint8_t)diff; in _Bocu1FromUnicodeWithOffsets()
636 cnv->fromUChar32= c<0 ? -c : 0; in _Bocu1FromUnicodeWithOffsets()
637 cnv->fromUnicodeStatus=(uint32_t)prev; in _Bocu1FromUnicodeWithOffsets()
640 pArgs->source=source; in _Bocu1FromUnicodeWithOffsets()
641 pArgs->target=(char *)target; in _Bocu1FromUnicodeWithOffsets()
642 pArgs->offsets=offsets; in _Bocu1FromUnicodeWithOffsets()
649 * re-copy the original function and remove the variables
660 int32_t prev, c, diff; in _Bocu1FromUnicode() local
663 cnv=pArgs->converter; in _Bocu1FromUnicode()
664 source=pArgs->source; in _Bocu1FromUnicode()
665 sourceLimit=pArgs->sourceLimit; in _Bocu1FromUnicode()
666 target=(uint8_t *)pArgs->target; in _Bocu1FromUnicode()
667 targetCapacity=(int32_t)(pArgs->targetLimit-pArgs->target); in _Bocu1FromUnicode()
670 c=cnv->fromUChar32; in _Bocu1FromUnicode()
671 prev=(int32_t)cnv->fromUnicodeStatus; in _Bocu1FromUnicode()
682 /* fast loop for single-byte differences */ in _Bocu1FromUnicode()
684 diff=(int32_t)(sourceLimit-source); in _Bocu1FromUnicode()
685 if(targetCapacity>diff) { in _Bocu1FromUnicode()
686 targetCapacity=diff; in _Bocu1FromUnicode()
695 diff=c-prev; in _Bocu1FromUnicode()
696 if(DIFF_IS_SINGLE(diff)) { in _Bocu1FromUnicode()
698 *target++=(uint8_t)PACK_SINGLE_DIFF(diff); in _Bocu1FromUnicode()
704 --targetCapacity; in _Bocu1FromUnicode()
707 targetCapacity=(int32_t)((const uint8_t *)pArgs->targetLimit-target); in _Bocu1FromUnicode()
724 --targetCapacity; in _Bocu1FromUnicode()
739 … c=-c; /* negative lead surrogate as "incomplete" indicator to avoid c=0 everywhere else */ in _Bocu1FromUnicode()
746 * are encoded with the difference c-prev in _Bocu1FromUnicode()
749 * placed in the middle of a 0x80-block (for most small scripts) or in _Bocu1FromUnicode()
753 diff=c-prev; in _Bocu1FromUnicode()
755 if(DIFF_IS_SINGLE(diff)) { in _Bocu1FromUnicode()
756 *target++=(uint8_t)PACK_SINGLE_DIFF(diff); in _Bocu1FromUnicode()
757 --targetCapacity; in _Bocu1FromUnicode()
761 } else if(DIFF_IS_DOUBLE(diff) && 2<=targetCapacity) { in _Bocu1FromUnicode()
762 /* optimize 2-byte case */ in _Bocu1FromUnicode()
765 if(diff>=0) { in _Bocu1FromUnicode()
766 diff-=BOCU1_REACH_POS_1+1; in _Bocu1FromUnicode()
767 m=diff%BOCU1_TRAIL_COUNT; in _Bocu1FromUnicode()
768 diff/=BOCU1_TRAIL_COUNT; in _Bocu1FromUnicode()
769 diff+=BOCU1_START_POS_2; in _Bocu1FromUnicode()
771 diff-=BOCU1_REACH_NEG_1; in _Bocu1FromUnicode()
772 NEGDIVMOD(diff, BOCU1_TRAIL_COUNT, m); in _Bocu1FromUnicode()
773 diff+=BOCU1_START_NEG_2; in _Bocu1FromUnicode()
775 *target++=(uint8_t)diff; in _Bocu1FromUnicode()
777 targetCapacity-=2; in _Bocu1FromUnicode()
781 diff=packDiff(diff); in _Bocu1FromUnicode()
782 length=BOCU1_LENGTH_FROM_PACKED(diff); in _Bocu1FromUnicode()
784 /* write the output character bytes from diff and length */ in _Bocu1FromUnicode()
790 *target++=(uint8_t)(diff>>24); in _Bocu1FromUnicode()
793 *target++=(uint8_t)(diff>>16); in _Bocu1FromUnicode()
795 *target++=(uint8_t)(diff>>8); in _Bocu1FromUnicode()
797 *target++=(uint8_t)diff; in _Bocu1FromUnicode()
803 targetCapacity-=length; in _Bocu1FromUnicode()
814 length-=targetCapacity; in _Bocu1FromUnicode()
815 charErrorBuffer=(uint8_t *)cnv->charErrorBuffer; in _Bocu1FromUnicode()
819 *charErrorBuffer++=(uint8_t)(diff>>16); in _Bocu1FromUnicode()
822 *charErrorBuffer++=(uint8_t)(diff>>8); in _Bocu1FromUnicode()
825 *charErrorBuffer=(uint8_t)diff; in _Bocu1FromUnicode()
831 cnv->charErrorBufferLength=(int8_t)length; in _Bocu1FromUnicode()
834 diff>>=8*length; /* length was reduced by targetCapacity */ in _Bocu1FromUnicode()
838 *target++=(uint8_t)(diff>>16); in _Bocu1FromUnicode()
841 *target++=(uint8_t)(diff>>8); in _Bocu1FromUnicode()
844 *target++=(uint8_t)diff; in _Bocu1FromUnicode()
865 cnv->fromUChar32= c<0 ? -c : 0; in _Bocu1FromUnicode()
866 cnv->fromUnicodeStatus=(uint32_t)prev; in _Bocu1FromUnicode()
869 pArgs->source=source; in _Bocu1FromUnicode()
870 pArgs->target=(char *)target; in _Bocu1FromUnicode()
873 /* BOCU-1-to-Unicode conversion functions ----------------------------------- */
876 * Function for BOCU-1 decoder; handles multi-byte lead bytes.
880 * @return (diff<<2)|count
884 int32_t diff, count; in decodeBocu1LeadByte() local
890 diff=((int32_t)b-BOCU1_START_POS_2)*BOCU1_TRAIL_COUNT+BOCU1_REACH_POS_1+1; in decodeBocu1LeadByte()
894diff=((int32_t)b-BOCU1_START_POS_3)*BOCU1_TRAIL_COUNT*BOCU1_TRAIL_COUNT+BOCU1_REACH_POS_2+1; in decodeBocu1LeadByte()
898 diff=BOCU1_REACH_POS_3+1; in decodeBocu1LeadByte()
905 diff=((int32_t)b-BOCU1_START_NEG_2)*BOCU1_TRAIL_COUNT+BOCU1_REACH_NEG_1; in decodeBocu1LeadByte()
909diff=((int32_t)b-BOCU1_START_NEG_3)*BOCU1_TRAIL_COUNT*BOCU1_TRAIL_COUNT+BOCU1_REACH_NEG_2; in decodeBocu1LeadByte()
913 diff=-BOCU1_TRAIL_COUNT*BOCU1_TRAIL_COUNT*BOCU1_TRAIL_COUNT+BOCU1_REACH_NEG_3; in decodeBocu1LeadByte()
919 return (diff<<2)|count; in decodeBocu1LeadByte()
923 * Function for BOCU-1 decoder; handles multi-byte trail bytes.
927 * @return new delta for diff including b - <0 indicates an error
939 return -99; in decodeBocu1TrailByte()
942 b-=BOCU1_TRAIL_BYTE_OFFSET; in decodeBocu1TrailByte()
964 int32_t prev, count, diff, c; in _Bocu1ToUnicodeWithOffsets() local
972 cnv=pArgs->converter; in _Bocu1ToUnicodeWithOffsets()
973 source=(const uint8_t *)pArgs->source; in _Bocu1ToUnicodeWithOffsets()
974 sourceLimit=(const uint8_t *)pArgs->sourceLimit; in _Bocu1ToUnicodeWithOffsets()
975 target=pArgs->target; in _Bocu1ToUnicodeWithOffsets()
976 targetLimit=pArgs->targetLimit; in _Bocu1ToUnicodeWithOffsets()
977 offsets=pArgs->offsets; in _Bocu1ToUnicodeWithOffsets()
980 prev=(int32_t)cnv->toUnicodeStatus; in _Bocu1ToUnicodeWithOffsets()
984 diff=cnv->mode; /* mode may be set to UCNV_SI by ucnv_bld.c but then toULength==0 */ in _Bocu1ToUnicodeWithOffsets()
985 count=diff&3; in _Bocu1ToUnicodeWithOffsets()
986 diff>>=2; in _Bocu1ToUnicodeWithOffsets()
988 byteIndex=cnv->toULength; in _Bocu1ToUnicodeWithOffsets()
989 bytes=cnv->toUBytes; in _Bocu1ToUnicodeWithOffsets()
991 /* sourceIndex=-1 if the current character began in the previous buffer */ in _Bocu1ToUnicodeWithOffsets()
992 sourceIndex=byteIndex==0 ? 0 : -1; in _Bocu1ToUnicodeWithOffsets()
1001 /* fast loop for single-byte differences */ in _Bocu1ToUnicodeWithOffsets()
1003 diff=(int32_t)(sourceLimit-source); in _Bocu1ToUnicodeWithOffsets()
1004 count=(int32_t)(pArgs->targetLimit-target); in _Bocu1ToUnicodeWithOffsets()
1005 if(count>diff) { in _Bocu1ToUnicodeWithOffsets()
1006 count=diff; in _Bocu1ToUnicodeWithOffsets()
1010 c=prev+(c-BOCU1_MIDDLE); in _Bocu1ToUnicodeWithOffsets()
1028 --count; in _Bocu1ToUnicodeWithOffsets()
1043 /* Write a code point directly from a single-byte difference. */ in _Bocu1ToUnicodeWithOffsets()
1044 c=prev+(c-BOCU1_MIDDLE); in _Bocu1ToUnicodeWithOffsets()
1054 * Direct-encoded C0 control code or space. in _Bocu1ToUnicodeWithOffsets()
1065 /* Optimize two-byte case. */ in _Bocu1ToUnicodeWithOffsets()
1067 diff=((int32_t)c-BOCU1_START_POS_2)*BOCU1_TRAIL_COUNT+BOCU1_REACH_POS_1+1; in _Bocu1ToUnicodeWithOffsets()
1069 diff=((int32_t)c-BOCU1_START_NEG_2)*BOCU1_TRAIL_COUNT+BOCU1_REACH_NEG_1; in _Bocu1ToUnicodeWithOffsets()
1075 if(c<0 || (uint32_t)(c=prev+diff+c)>0x10ffff) { in _Bocu1ToUnicodeWithOffsets()
1076 bytes[0]=source[-2]; in _Bocu1ToUnicodeWithOffsets()
1077 bytes[1]=source[-1]; in _Bocu1ToUnicodeWithOffsets()
1089 * For multi-byte difference lead bytes, set the decoder state in _Bocu1ToUnicodeWithOffsets()
1096 diff=decodeBocu1LeadByte(c); in _Bocu1ToUnicodeWithOffsets()
1097 count=diff&3; in _Bocu1ToUnicodeWithOffsets()
1098 diff>>=2; in _Bocu1ToUnicodeWithOffsets()
1114 diff+=c; in _Bocu1ToUnicodeWithOffsets()
1115 if(--count==0) { in _Bocu1ToUnicodeWithOffsets()
1118 c=prev+diff; in _Bocu1ToUnicodeWithOffsets()
1143 cnv->UCharErrorBuffer[0]=U16_TRAIL(c); in _Bocu1ToUnicodeWithOffsets()
1144 cnv->UCharErrorBufferLength=1; in _Bocu1ToUnicodeWithOffsets()
1155 cnv->toUnicodeStatus=BOCU1_ASCII_PREV; in _Bocu1ToUnicodeWithOffsets()
1156 cnv->mode=0; in _Bocu1ToUnicodeWithOffsets()
1159 cnv->toUnicodeStatus=(uint32_t)prev; in _Bocu1ToUnicodeWithOffsets()
1160 cnv->mode=(diff<<2)|count; in _Bocu1ToUnicodeWithOffsets()
1162 cnv->toULength=byteIndex; in _Bocu1ToUnicodeWithOffsets()
1165 pArgs->source=(const char *)source; in _Bocu1ToUnicodeWithOffsets()
1166 pArgs->target=target; in _Bocu1ToUnicodeWithOffsets()
1167 pArgs->offsets=offsets; in _Bocu1ToUnicodeWithOffsets()
1175 * re-copy the original function and remove the variables
1186 int32_t prev, count, diff, c; in _Bocu1ToUnicode() local
1192 cnv=pArgs->converter; in _Bocu1ToUnicode()
1193 source=(const uint8_t *)pArgs->source; in _Bocu1ToUnicode()
1194 sourceLimit=(const uint8_t *)pArgs->sourceLimit; in _Bocu1ToUnicode()
1195 target=pArgs->target; in _Bocu1ToUnicode()
1196 targetLimit=pArgs->targetLimit; in _Bocu1ToUnicode()
1199 prev=(int32_t)cnv->toUnicodeStatus; in _Bocu1ToUnicode()
1203 diff=cnv->mode; /* mode may be set to UCNV_SI by ucnv_bld.c but then toULength==0 */ in _Bocu1ToUnicode()
1204 count=diff&3; in _Bocu1ToUnicode()
1205 diff>>=2; in _Bocu1ToUnicode()
1207 byteIndex=cnv->toULength; in _Bocu1ToUnicode()
1208 bytes=cnv->toUBytes; in _Bocu1ToUnicode()
1216 /* fast loop for single-byte differences */ in _Bocu1ToUnicode()
1218 diff=(int32_t)(sourceLimit-source); in _Bocu1ToUnicode()
1219 count=(int32_t)(pArgs->targetLimit-target); in _Bocu1ToUnicode()
1220 if(count>diff) { in _Bocu1ToUnicode()
1221 count=diff; in _Bocu1ToUnicode()
1225 c=prev+(c-BOCU1_MIDDLE); in _Bocu1ToUnicode()
1241 --count; in _Bocu1ToUnicode()
1254 /* Write a code point directly from a single-byte difference. */ in _Bocu1ToUnicode()
1255 c=prev+(c-BOCU1_MIDDLE); in _Bocu1ToUnicode()
1263 * Direct-encoded C0 control code or space. in _Bocu1ToUnicode()
1272 /* Optimize two-byte case. */ in _Bocu1ToUnicode()
1274 diff=((int32_t)c-BOCU1_START_POS_2)*BOCU1_TRAIL_COUNT+BOCU1_REACH_POS_1+1; in _Bocu1ToUnicode()
1276 diff=((int32_t)c-BOCU1_START_NEG_2)*BOCU1_TRAIL_COUNT+BOCU1_REACH_NEG_1; in _Bocu1ToUnicode()
1281 if(c<0 || (uint32_t)(c=prev+diff+c)>0x10ffff) { in _Bocu1ToUnicode()
1282 bytes[0]=source[-2]; in _Bocu1ToUnicode()
1283 bytes[1]=source[-1]; in _Bocu1ToUnicode()
1294 * For multi-byte difference lead bytes, set the decoder state in _Bocu1ToUnicode()
1301 diff=decodeBocu1LeadByte(c); in _Bocu1ToUnicode()
1302 count=diff&3; in _Bocu1ToUnicode()
1303 diff>>=2; in _Bocu1ToUnicode()
1318 diff+=c; in _Bocu1ToUnicode()
1319 if(--count==0) { in _Bocu1ToUnicode()
1322 c=prev+diff; in _Bocu1ToUnicode()
1343 cnv->UCharErrorBuffer[0]=U16_TRAIL(c); in _Bocu1ToUnicode()
1344 cnv->UCharErrorBufferLength=1; in _Bocu1ToUnicode()
1354 cnv->toUnicodeStatus=BOCU1_ASCII_PREV; in _Bocu1ToUnicode()
1355 cnv->mode=0; in _Bocu1ToUnicode()
1358 cnv->toUnicodeStatus=(uint32_t)prev; in _Bocu1ToUnicode()
1359 cnv->mode=(diff<<2)|count; in _Bocu1ToUnicode()
1361 cnv->toULength=byteIndex; in _Bocu1ToUnicode()
1364 pArgs->source=(const char *)source; in _Bocu1ToUnicode()
1365 pArgs->target=target; in _Bocu1ToUnicode()
1369 /* miscellaneous ------------------------------------------------------------ */
1399 "BOCU-1",
1400 1214, /* CCSID for BOCU-1 */
1403 { 0x1a, 0, 0, 0 }, 1, /* BOCU-1 never needs to write a subchar */