Fixes QIconvCodec::convertToUnicode()
authorNick Ratelle <nratelle@qnx.com>
Mon, 19 Dec 2011 14:53:35 +0000 (10:53 -0400)
committerQt by Nokia <qt-info@nokia.com>
Sun, 5 Feb 2012 09:07:48 +0000 (10:07 +0100)
We need to hang onto the internal state of the utf16 converter
object whenever converting a long string to unicode. This was
failing with the text stream class -- the first read was okay,
but subsequent reads could not be correctly converted to unicode.

Change-Id: I9e2d445d51c9009591bfa7a1765ea2d09ae634a2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/corelib/codecs/qiconvcodec.cpp
src/corelib/codecs/qiconvcodec_p.h

index 1941b70..aa0ddca 100644 (file)
@@ -286,12 +286,16 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
         }
     } while (inBytesLeft != 0);
 
-    QString s = utf16Codec->toUnicode(ba.constData(), ba.size() - outBytesLeft);
+    QString s;
 
     if (convState) {
+        s = utf16Codec->toUnicode(ba.constData(), ba.size() - outBytesLeft, &state->internalState);
+
         convState->invalidChars = invalidCount;
         convState->remainingChars = remainingCount;
     } else {
+        s = utf16Codec->toUnicode(ba.constData(), ba.size() - outBytesLeft);
+
         // reset state
         iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
     }
index c4ea460..efe3b4b 100644 (file)
@@ -87,6 +87,7 @@ public:
     public:
         IconvState(iconv_t x);
         ~IconvState();
+        ConverterState internalState;
         char *buffer;
         int bufferLen;
         iconv_t cd;