[Development] qPrintable encoding issues
Koehne Kai
Kai.Koehne at digia.com
Fri Feb 28 10:16:52 CET 2014
> -----Original Message-----
> From: development-bounces+kai.koehne=digia.com at qt-project.org
>
> [...]
> What about adding e.g. qRawUtf8() which would do like qPrintable but
> toUtf8() instead of toLocal8Bit()?
I've been pondering with this something similar too, since
qDebug("%s", string.toUtf8().constData());
isn't really short and crisp ... But I just found out that there's a more elegant way: QString::snprintf and therefore also qDebug() and friends support the %ls placeholder, so you can write
qDebug("%ls", string.utf16());
> (If you don't otherwise care about doing conversions to local-8-bit, couldn't
> you also set the string locale to UTF-8?)
Sorry, I didn't get this question / proposal :) The issue is that qPrintable might be used in all sort of contexts, so changing its behavior for sure breaks code.
Regards
Kai
More information about the Development
mailing list