Fix compile with Qt 6.9

The QString::arg overload that accepts a base is explicitly disabled for
everything that can be cast to a QAnyStringView, so for example
T==char32_t or T==char16_t will is not usable in that overload. And the
overload that accepts those types does not allow to set the base. Fix
this by using T==int32_t or T==int16_t.

Change-Id: Ib23a2ced7e03dab6de50458d36bc27689c6f8da9
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
David Schulz
2024-12-10 11:30:49 +01:00
parent f2cb102c77
commit 7abf8ae477
3 changed files with 4 additions and 4 deletions

View File

@@ -268,7 +268,7 @@ QString asciify(const QString &input)
if (c.isPrint() && c.unicode() < 128)
result.append(c);
else
result.append(QString::fromLatin1("u%1").arg(c.unicode(), 4, 16, QChar('0')));
result.append(QString::fromLatin1("u%1").arg(int16_t(c.unicode()), 4, 16, QChar('0')));
}
return result;
}

View File

@@ -254,8 +254,8 @@ QString escapeUnprintable(const QString &str, int unprintableBase)
QString encoded;
while (arrayView.size() >= 4) {
char32_t c;
memcpy(&c, arrayView.constData(), sizeof(char32_t));
int32_t c;
memcpy(&c, arrayView.constData(), sizeof(int32_t));
if (QChar::isPrint(c))
encoded += toQString(arrayView.sliced(0, 4));

View File

@@ -975,7 +975,7 @@ QString quoteUnprintable(const QString &ba)
else if (cc == '\n')
res += "<CR>";
else
res += QString("\\x%1").arg(c.unicode(), 2, 16, QLatin1Char('0'));
res += QString("\\x%1").arg(int16_t(c.unicode()), 2, 16, QLatin1Char('0'));
}
return res;
}