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>
This commit is contained in:
Nick Ratelle 2011-12-19 10:53:35 -04:00 committed by Qt by Nokia
parent fc24979e43
commit 72c0731122
2 changed files with 6 additions and 1 deletions

View 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);
}

View File

@ -87,6 +87,7 @@ public:
public:
IconvState(iconv_t x);
~IconvState();
ConverterState internalState;
char *buffer;
int bufferLen;
iconv_t cd;