diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-04-28 11:47:21 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-05-01 18:53:21 +0200 |
commit | be04ee67deb2955f0e1f5915fb17c5411377f7d4 (patch) | |
tree | a1ba4952bc7d0090d08ada891c024f1291436108 /src/corelib/codecs | |
parent | 0a02a598a429ceba17cbe85a5fbf167730a4038b (diff) |
Correctly flag remaining chars for the ICU codec
This will help us get rid of an extremely ugly hack in
QTextStream, where we copy the state.
Change-Id: If3e15eeb4e35c8607be54dd11c09ddfed87a4d93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r-- | src/corelib/codecs/qicucodec.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp index f9092277b2..8a6dfc756f 100644 --- a/src/corelib/codecs/qicucodec.cpp +++ b/src/corelib/codecs/qicucodec.cpp @@ -614,6 +614,9 @@ QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::C qDebug("convertToUnicode failed: %s", u_errorName(error)); break; } + // flag the state if we have incomplete input + if (error == U_TRUNCATED_CHAR_FOUND) + state->remainingChars = 1; convertedChars = uc - (UChar *)string.data(); if (chars >= end) @@ -649,6 +652,10 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QText nullptr, false, &error); if (!U_SUCCESS(error)) qDebug("convertFromUnicode failed: %s", u_errorName(error)); + // flag the state if we have incomplete input + if (error == U_TRUNCATED_CHAR_FOUND) + state->remainingChars = 1; + convertedChars = ch - string.data(); if (uc >= end) break; |