From d80b0eb12c477592b590b768e21dc26c137beadc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 9 Jan 2018 10:24:18 -0800 Subject: Doc: make a note about use of QStringLiteral with non-ASCII chars Both ICC and MSVC have bugs concatenating strings and that's despite the standard giving an example ([lex.string] table 9) that says that u"a" "b" is the same as u"ab" We can't change to preprocessor concatenation (u ## STR) because that fails when QStringLiteral is used with a macro instead of an actual string literal. Task-number: QTBUG-65479 Change-Id: I39332e0a867442d58082fffd1504a0a868c291ef Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index c0a03e0011..aff384a257 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -10802,7 +10802,7 @@ QString QString::toHtmlEscaped() const This cost can be avoided by using QStringLiteral instead: \code - if (node.hasAttribute(QStringLiteral("http-contents-length"))) //... + if (node.hasAttribute(QStringLiteral(u"http-contents-length"))) //... \endcode In this case, QString's internal data will be generated at compile time; no @@ -10822,6 +10822,10 @@ QString QString::toHtmlEscaped() const if (attribute.name() == QLatin1String("http-contents-length")) //... \endcode + \note Some compilers have bugs encoding strings containing characters outside + the US-ASCII character set. Make sure you prefix your string with \c{u} in + those cases. It is optional otherwise. + \sa QByteArrayLiteral */ -- cgit v1.2.3