diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-26 23:42:28 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-26 23:42:28 (GMT) |
commit | 59c58576efd3ceff7add46a359fd99e56a2fb279 (patch) | |
tree | a23982655f3f7959c9c340b429aebc51435e6676 /src/plugins | |
parent | d8f757bdb881c3a3d723642734d7d76fae14dce7 (diff) | |
parent | 1a72f98a15ef78004894dc6636b8a5d969d66fde (diff) | |
download | Qt-59c58576efd3ceff7add46a359fd99e56a2fb279.zip Qt-59c58576efd3ceff7add46a359fd99e56a2fb279.tar.gz Qt-59c58576efd3ceff7add46a359fd99e56a2fb279.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1:
Fixed copy-paste error in htmlgenerator.cpp
Corrected filename case for wincrypt.h
Add qDebug() operator for QGLFormat
Fix conversion between JavaScript Date and QDateTime
Avoid memory allocation when converting from Gbk to unicode.
Warn if surface creation fails
Doc: fixing search bug
doc: Added more DITA output to the XML generator
QSemaphore::tryAquire(timeout) -- never times out on an active semaphore
Fix warnings in QSslSocketPrivate::systemCaCertificates()
doc: Added more DITA output to the XML generator
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/codecs/cn/qgb18030codec.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/codecs/cn/qgb18030codec.cpp b/src/plugins/codecs/cn/qgb18030codec.cpp index 3f2eec7..e10c8b1 100644 --- a/src/plugins/codecs/cn/qgb18030codec.cpp +++ b/src/plugins/codecs/cn/qgb18030codec.cpp @@ -319,7 +319,7 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState * { uchar buf[2]; int nbuf = 0; - QChar replacement = QChar::ReplacementCharacter; + ushort replacement = QChar::ReplacementCharacter; if (state) { if (state->flags & ConvertInvalidToNull) replacement = QChar::Null; @@ -330,6 +330,9 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState * int invalid = 0; QString result; + result.resize(len); + int unicodeLen = 0; + ushort *const resultData = reinterpret_cast<ushort*>(result.data()); //qDebug("QGbkDecoder::toUnicode(const char* chars = \"%s\", int len = %d)", chars, len); for (int i=0; i<len; i++) { @@ -338,14 +341,16 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState * case 0: if (ch < 0x80) { // ASCII - result += QLatin1Char(ch); + resultData[unicodeLen] = ch; + ++unicodeLen; } else if (Is1stByte(ch)) { // GBK 1st byte? buf[0] = ch; nbuf = 1; } else { // Invalid - result += replacement; + resultData[unicodeLen] = replacement; + ++unicodeLen; ++invalid; } break; @@ -356,21 +361,25 @@ QString QGbkCodec::convertToUnicode(const char* chars, int len, ConverterState * int clen = 2; uint u = qt_Gb18030ToUnicode(buf, clen); if (clen == 2) { - result += qValidChar(u); + resultData[unicodeLen] = qValidChar(static_cast<ushort>(u)); + ++unicodeLen; } else { - result += replacement; + resultData[unicodeLen] = replacement; + ++unicodeLen; ++invalid; } nbuf = 0; } else { // Error - result += replacement; + resultData[unicodeLen] = replacement; + ++unicodeLen; ++invalid; nbuf = 0; } break; } } + result.resize(unicodeLen); if (state) { state->remainingChars = nbuf; |