[Development] qPrintable encoding issues

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Feb 21 16:48:18 CET 2014


On 2014-02-21 04:20, Koehne Kai wrote:
> This is a heads up that you should avoid using qPrintable() together
> with qDebug/QDebug for localized strings.
>
> The issue is that qPrintable() does '.toLocal8Bit()', while
> QDebug/qDebug and friends nowadays expect const char * arguments to
> be UTF-8 encoded.

When you say "nowadays", has something changed? (In particular, is the 
above true of Qt 4.x also?)

> Other ideas how to fix this are of course welcome :)

What about adding e.g. qRawUtf8() which would do like qPrintable but 
toUtf8() instead of toLocal8Bit()?

(If you don't otherwise care about doing conversions to local-8-bit, 
couldn't you also set the string locale to UTF-8?)

-- 
Matthew




More information about the Development mailing list