diff options
author | Nick Ratelle <nratelle@qnx.com> | 2011-12-19 14:53:35 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-07 00:20:02 (GMT) |
commit | b4efb21eb01fdede5ff8d609f0e4d8cee4d8eea7 (patch) | |
tree | 5e29b039c5daf463156f99e7ae169710f2fb3a64 /src/corelib | |
parent | fdda0af131095b0f5479b3fe183bbd0b613cce58 (diff) | |
download | Qt-b4efb21eb01fdede5ff8d609f0e4d8cee4d8eea7.zip Qt-b4efb21eb01fdede5ff8d609f0e4d8cee4d8eea7.tar.gz Qt-b4efb21eb01fdede5ff8d609f0e4d8cee4d8eea7.tar.bz2 |
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.
cherry-picked from qt5/qtbase: 72c07311228ce6eefb460d7e5da3de24220ba81e
Change-Id: I794d78808ccd9deedcb406bfe46e373c18142d05
Reviewed-by: Thiago Macieira <thiago.macieira@intel.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 59c77ba..3b15d11 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 fb2d89e..d305210 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; |