diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-04-12 18:21:39 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-13 10:44:28 +0200 |
commit | 9fd2edb6da5f1f6d644cd7c3f35aebe3e88beee2 (patch) | |
tree | d644aeef68584469ec1b9b6cdbc3d86cc7ddf86b /src/corelib/codecs | |
parent | b317fe2a606e5b79f24b1e4a1b808f5ff66d3621 (diff) |
replace hardcoded values with a surrogate handling methods
Change-Id: Ib41e08d835f2e8ca2e32b4025c6f5a99840f2e27
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r-- | src/corelib/codecs/qutfcodec.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index 18d063a38c..9111ac6379 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -127,7 +127,7 @@ QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::Conve continue; } - if (u > 0xffff) { + if (QChar::requiresSurrogates(u)) { *cursor++ = 0xf0 | ((uchar) (u >> 18)); *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); } else { @@ -196,7 +196,7 @@ QString QUtf8::convertToUnicode(const char *chars, int len, QTextCodec::Converte bool nonCharacter; if (!headerdone && uc == 0xfeff) { // don't do anything, just skip the BOM - } else if (!(nonCharacter = isUnicodeNonCharacter(uc)) && uc > 0xffff && uc < 0x110000) { + } else if (!(nonCharacter = isUnicodeNonCharacter(uc)) && QChar::requiresSurrogates(uc) && uc < 0x110000) { // surrogate pair Q_ASSERT((qch - (ushort*)result.unicode()) + 2 < result.length()); *qch++ = QChar::highSurrogate(uc); @@ -487,7 +487,7 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert } } uint code = (endian == BigEndianness) ? qFromBigEndian<quint32>(tuple) : qFromLittleEndian<quint32>(tuple); - if (code >= 0x10000) { + if (QChar::requiresSurrogates(code)) { *qch++ = QChar::highSurrogate(code); *qch++ = QChar::lowSurrogate(code); } else { |