diff options
author | Nick Ratelle <nratelle@qnx.com> | 2011-12-19 10:53:35 -0400 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-05 10:07:48 +0100 |
commit | 72c07311228ce6eefb460d7e5da3de24220ba81e (patch) | |
tree | 633b28d69166653bf300593050721d4cb416d6fc /src/corelib | |
parent | fc24979e43162b27b7a482fd4963ae615f5ce54f (diff) |
Fixes QIconvCodec::convertToUnicode()
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>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qiconvcodec.cpp | 6 | ||||
-rw-r--r-- | src/corelib/codecs/qiconvcodec_p.h | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 1941b70f24..aa0ddca753 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -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); } diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h index c4ea4600e8..efe3b4b5f7 100644 --- a/src/corelib/codecs/qiconvcodec_p.h +++ b/src/corelib/codecs/qiconvcodec_p.h @@ -87,6 +87,7 @@ public: public: IconvState(iconv_t x); ~IconvState(); + ConverterState internalState; char *buffer; int bufferLen; iconv_t cd; |