diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-07-20 19:21:06 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-07-22 11:05:50 +0000 |
commit | c1991c63fc081a42ed3e6a28f82f395c54ef42a1 (patch) | |
tree | 4d6918481649e48079e1355d041ed5a7309395fe /src/corelib/text/qstring.cpp | |
parent | 929bb153eeb9e2c49778f65829146d11b815767a (diff) |
Fix QString::toHtmlEscaped() for >2Gi character strings
More unfinished int → qsizetype porting.
Fixes: QTBUG-105104
Pick-to: 6.4 6.3 6.2
Change-Id: I3470de31c476b3d7736661550916828e43546573
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text/qstring.cpp')
-rw-r--r-- | src/corelib/text/qstring.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 1a78c1d0cd..2507802b6b 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -10896,19 +10896,19 @@ qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re) QString QString::toHtmlEscaped() const { QString rich; - const int len = length(); + const qsizetype len = length(); rich.reserve(qsizetype(len * 1.1)); - for (int i = 0; i < len; ++i) { - if (at(i) == u'<') + for (QChar ch : *this) { + if (ch == u'<') rich += "<"_L1; - else if (at(i) == u'>') + else if (ch == u'>') rich += ">"_L1; - else if (at(i) == u'&') + else if (ch == u'&') rich += "&"_L1; - else if (at(i) == u'"') + else if (ch == u'"') rich += """_L1; else - rich += at(i); + rich += ch; } rich.squeeze(); return rich; |