diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 295af01f8c..030c606047 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -692,12 +692,8 @@ static QTtfTable generateName(const QList &name) off += len; } for (int i = 0; i < name.size(); ++i) { - const QString &n = name.at(i).value; - const ushort *uc = n.utf16(); - for (int i = 0; i < n.length(); ++i) { - s << quint16(*uc); - ++uc; - } + for (QChar ch : name.at(i).value) + s << quint16(ch.unicode()); } return t; } diff --git a/src/gui/text/windows/qwindowsfontdatabasebase.cpp b/src/gui/text/windows/qwindowsfontdatabasebase.cpp index 4ee2c42b8a..566941eca9 100644 --- a/src/gui/text/windows/qwindowsfontdatabasebase.cpp +++ b/src/gui/text/windows/qwindowsfontdatabasebase.cpp @@ -274,14 +274,11 @@ QString QWindowsFontDatabaseBase::EmbeddedFont::changeFamilyName(const QString & // nameRecord now points to string data quint16 *stringStorage = reinterpret_cast(nameRecord); - const quint16 *sourceString = newFamilyName.utf16(); - for (int i = 0; i < newFamilyName.size(); ++i) - stringStorage[i] = qbswap(sourceString[i]); - stringStorage += newFamilyName.size(); + for (QChar ch : newFamilyName) + *stringStorage++ = qbswap(quint16(ch.unicode())); - sourceString = regularString.utf16(); - for (int i = 0; i < regularString.size(); ++i) - stringStorage[i] = qbswap(sourceString[i]); + for (QChar ch : regularString) + *stringStorage++ = qbswap(quint16(ch.unicode())); } quint32 *p = reinterpret_cast(newNameTable.data()); diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index ba61f66115..3240240882 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1067,9 +1067,9 @@ static void qStreamNtlmString(QDataStream& ds, const QString& s, bool unicode) qStreamNtlmBuffer(ds, s.toLatin1()); return; } - const ushort *d = s.utf16(); - for (int i = 0; i < s.length(); ++i) - ds << d[i]; + + for (QChar ch : s) + ds << quint16(ch.unicode()); } @@ -1210,11 +1210,10 @@ static QByteArray qNtlmPhase1() static QByteArray qStringAsUcs2Le(const QString& src) { QByteArray rc(2*src.length(), 0); - const unsigned short *s = src.utf16(); unsigned short *d = (unsigned short*)rc.data(); - for (int i = 0; i < src.length(); ++i) { - d[i] = qToLittleEndian(s[i]); - } + for (QChar ch : src) + *d++ = qToLittleEndian(quint16(ch.unicode())); + return rc; }