Document qPrintable encoding issues

Change-Id: I8936203afaa100ac4665ed668f7729fc8da1d445
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
bb10
Kai Koehne 2014-02-24 09:29:41 +01:00 committed by The Qt Project
parent 2f76a30ee1
commit 7129ec0f47
1 changed files with 6 additions and 1 deletions

View File

@ -2810,12 +2810,17 @@ int qrand()
The char pointer will be invalid after the statement in which
qPrintable() is used. This is because the array returned by
toLocal8Bit() will fall out of scope.
QString::toLocal8Bit() will fall out of scope.
Example:
\snippet code/src_corelib_global_qglobal.cpp 37
\note qDebug(), qWarning(), qCritical(), qFatal() expect %s
arguments to be UTF-8 encoded, while qPrintable() converts to
local 8-bit encoding. Therefore using qPrintable for logging
strings is only safe if the argument contains only ASCII
characters.
\sa qDebug(), qWarning(), qCritical(), qFatal()
*/