diff options
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 0169b20..6acbcec 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -939,11 +939,11 @@ int QString::toWCharArray(wchar_t *array) const const unsigned short *uc = utf16(); for (int i = 0; i < length(); ++i) { uint u = uc[i]; - if (u >= 0xd800 && u < 0xdc00 && i < length()-1) { + if (QChar::isHighSurrogate(u) && i + 1 < length()) { ushort low = uc[i+1]; - if (low >= 0xdc00 && low < 0xe000) { + if (QChar::isLowSurrogate(low)) { + u = QChar::surrogateToUcs4(u, low); ++i; - u = (u - 0xd800)*0x400 + (low - 0xdc00) + 0x10000; } } *a = wchar_t(u); @@ -6195,8 +6195,10 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar:: if (simple) return; - QString &s = *data; - if (version != UNICODE_DATA_VERSION) { + if (version == QChar::Unicode_Unassigned) { + version = UNICODE_DATA_VERSION; + } else if (version != UNICODE_DATA_VERSION) { + QString &s = *data; for (int i = 0; i < NumNormalizationCorrections; ++i) { const NormalizationCorrection &n = uc_normalization_corrections[i]; if (n.version > version) { @@ -7385,7 +7387,7 @@ QString &QString::setRawData(const QChar *unicode, int size) Writes the given \a string to the specified \a stream. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator<<(QDataStream &out, const QString &str) @@ -7433,7 +7435,7 @@ QDataStream &operator<<(QDataStream &out, const QString &str) Reads a string from the specified \a stream into the given \a string. - \sa {Format of the QDataStream Operators} + \sa {Serializing Qt Data Types} */ QDataStream &operator>>(QDataStream &in, QString &str) |