diff --git a/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp b/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp index 710a4ed0c1d..9de3f14fe22 100644 --- a/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp +++ b/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp @@ -161,45 +161,65 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByMultiTable( nsresult res = NS_OK; PRInt32 i; - while ((srcLen > 0) && (dest < destEnd)) { - for (i=0; i 0) && (dest < destEnd)) + { + PRBool done= PR_FALSE; + for (i=0; (!done) && (i= 2 && !(*(src+1) & 0x80) ) { - bcr-= (bcr-1); + if ((aRangeArray[i].min <= *src) && (*src <= aRangeArray[i].max)) + { + if (uScan(aShiftTable[i], NULL, src, + NS_REINTERPRET_CAST(PRUint16*, &med), srcLen, + (PRUint32 *)&bcr)) + { + done = uMapCode((uTable*) aMappingTable[i], + NS_STATIC_CAST(PRUint16, med), + NS_REINTERPRET_CAST(PRUint16*, dest)); + } // if (uScan ... ) + } // if Range + } // for loop + + if(! done) + { + bcr = 1; + if (med < 0x20) { + // somehow some table miss the 0x00 - 0x20 part + *dest = med; + } else { + // we need to decide how many byte we skip. We can use uScan to do this + for (i=0; i 0x80 + // if we hit bytes <= 0x80, skip only one byte + bcr = 1; + break; + } + } + break; } - // If stand-alone 0xa0 gets this far (BIG5), leave it alone. - // Otherwise, use Unicode replacement value for unmappable chars - *dest = (*src == (PRUint8)0xa0 ) ? 0x00a0 : 0xfffd; } - } + } + // treat it as NSBR if bcr == 1 and it is 0xa0 + *dest = ((1==bcr)&&(*src == (PRUint8)0xa0 )) ? 0x00a0 : 0xfffd; + } } src += bcr; srcLen -= bcr; dest++; - } + } // while if ((srcLen > 0) && (res == NS_OK)) res = NS_OK_UDEC_MOREOUTPUT;