equal
deleted
inserted
replaced
850 TInt bytesLeft = -1; |
850 TInt bytesLeft = -1; |
851 if (aCharconvForUtf8Conversion) |
851 if (aCharconvForUtf8Conversion) |
852 { |
852 { |
853 // Can be null if charconv is busted |
853 // Can be null if charconv is busted |
854 bytesLeft = aCharconvForUtf8Conversion->ConvertToUnicode(iData, data, state, numUnconverted, firstUnconverted); |
854 bytesLeft = aCharconvForUtf8Conversion->ConvertToUnicode(iData, data, state, numUnconverted, firstUnconverted); |
855 ASSERT(bytesLeft <= 0); // Otherwise we didn't make our buffer big enough |
855 ASSERT(bytesLeft <= 3); // Otherwise we didn't make our buffer big enough. There could be up to 3 bytes remaining if the block ends in a truncated UTF-8 sequence |
856 // bytesLeft less than zero means an invalid sequence at the start of the buffer. Since our block size will never be so small there's no risk it's the start of a truncated sequence |
856 // bytesLeft less than zero means an invalid sequence at the start of the buffer. Since our block size will never be so small there's no risk it's the start of a truncated sequence |
857 } |
857 } |
858 |
858 |
859 if (bytesLeft < 0) |
859 if (bytesLeft < 0) |
860 { |
860 { |
863 blockEncoding = EEncodingNarrow; |
863 blockEncoding = EEncodingNarrow; |
864 } |
864 } |
865 else if (firstUnconverted >= 0) |
865 else if (firstUnconverted >= 0) |
866 { |
866 { |
867 // Got some bad data |
867 // Got some bad data |
868 if (iNext && data.Length() - firstUnconverted < 4) |
868 if (iNext && data.Length() - bytesLeft < 4 && firstUnconverted == data.Length() - bytesLeft) |
869 { |
869 { |
870 // Possibly a UTF-8 sequence spread over a block boundary |
870 // Possibly a UTF-8 sequence spread over a block boundary |
871 blockEncoding = EEncodingUtf8; |
871 blockEncoding = EEncodingUtf8; |
872 TInt err = iNext->TransferDataFromPreviousBlock(this, data.Mid(firstUnconverted)); |
872 TInt err = iNext->TransferDataFromPreviousBlock(this, data.Right(bytesLeft)); |
873 if (!err) |
873 if (!err) |
874 { |
874 { |
875 iBlockSize = firstUnconverted; |
875 iBlockSize -= bytesLeft; |
876 } |
876 } |
877 iData.SetLength(iData.Locate(0xFFFD)); // No better way of figuring out where charconv barfed than to scan for the first instance of the substitution character |
877 iData.SetLength(iData.LocateReverse(0xFFFD)); // No better way of figuring out where charconv barfed than to scan for the last instance of the substitution character |
878 } |
878 } |
879 else |
879 else |
880 { |
880 { |
881 // It's just not UTF-8 |
881 // It's just not UTF-8 |
882 iData.Copy(aData); |
882 iData.Copy(aData); |