1 --- src/codecs/qutfcodec.cpp
2 +++ src/codecs/qutfcodec.cpp
5 class QUtf8Decoder : public QTextDecoder {
12 result.setLength( len ); // worst case
13 QChar *qch = (QChar *)result.unicode();
16 for (int i=0; i<len; i++) {
20 if ( (ch&0xc0) == 0x80 ) {
21 uc = (uc << 6) | (ch & 0x3f);
26 + } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) {
27 + *qch++ = QChar::replacement;
29 if (headerDone || QChar(uc) != QChar::byteOrderMark)
36 *qch++ = QChar::replacement;
40 } else if ((ch & 0xe0) == 0xc0) {
45 } else if ((ch & 0xf0) == 0xe0) {
50 } else if ((ch&0xf8) == 0xf0) {
57 + *qch++ = QChar::replacement;
61 --- src/tools/qstring.cpp
62 +++ src/tools/qstring.cpp
64 result.setLength( len ); // worst case
65 QChar *qch = (QChar *)result.unicode();
71 @@ -5822,6 +5823,12 @@
72 unsigned short low = uc%0x400 + 0xdc00;
75 + } else if (uc < min_uc || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) {
76 + // overlong seqence, UTF16 surrogate or BOM
78 + qch = addOne(qch, result);
79 + *qch++ = QChar(0xdbff);
80 + *qch++ = QChar(0xde00+((uchar)utf8[i]));
84 @@ -5844,14 +5851,17 @@
89 } else if ((ch & 0xf0) == 0xe0) {
94 } else if ((ch&0xf8) == 0xf0) {
101 qch = addOne(qch, result);