src/corelib/codecs/qiconvcodec.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   376         inBytesLeft += sizeof(QChar);
   376         inBytesLeft += sizeof(QChar);
   377         convState->remainingChars = 0;
   377         convState->remainingChars = 0;
   378     }
   378     }
   379 
   379 
   380     int invalidCount = 0;
   380     int invalidCount = 0;
   381     do {
   381     while (inBytesLeft != 0) {
   382         if (iconv(state->cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) {
   382         if (iconv(state->cd, inBytesPtr, &inBytesLeft, &outBytes, &outBytesLeft) == (size_t) -1) {
   383             if (errno == EINVAL && convState) {
   383             if (errno == EINVAL && convState) {
   384                 // buffer ends in a surrogate
   384                 // buffer ends in a surrogate
   385                 Q_ASSERT(inBytesLeft == 2);
   385                 Q_ASSERT(inBytesLeft == 2);
   386                 convState->remainingChars = 1;
   386                 convState->remainingChars = 1;
   416 
   416 
   417                     return QString(uc, len).toAscii();
   417                     return QString(uc, len).toAscii();
   418                 }
   418                 }
   419             }
   419             }
   420         }
   420         }
   421     } while (inBytesLeft != 0);
   421     }
   422 
   422 
   423     // reset to initial state
   423     // reset to initial state
   424     iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
   424     iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft);
   425 
   425 
   426     ba.resize(ba.size() - outBytesLeft);
   426     ba.resize(ba.size() - outBytesLeft);