[Development] FW: Backwards compatibiltiy break in Qt 5.5
Thiago Macieira
thiago.macieira at intel.com
Mon Jul 27 18:13:44 CEST 2015
On Monday 27 July 2015 08:44:30 Knoll Lars wrote:
> I can understand the issues that non latin speakers are facing with this
> well. I’ve often used qDebug() to debug non latin use cases, and in 90% of
> the cases I just want to know what the string reads. The unicode content
> of it is interesting to me in only 10% of the cases. For most users not
> debugging Qt’s internals I would assume that ratio to be more like 99 to 1.
As I said in my email, the problem is that you will not turn this on for those
10% of the cases until you've already lost data, either visibly or really. I'm
counting ambiguity and homographs as apparent data loss because it will send
you down the wrong debugging path.
> Thiago, which backends can’t handle utf8 or utf16 output these days?
Android log, slog2, syslog and the regular stderr output if the system locale
isn't UTF-8. In particular, on Windows the system locale is never UTF-8 unless
you're using Vietnamese Windows. On the other hand, the OS X system locale is
always UTF-8 unless you've messed up, including with setCodecForLocale.
Or, if I list those that always do: WIndows OutputDebugString and journald.
None of those are binary-safe, which means they will not work with a QString
containing a NUL character.
> One idea could be a slightly modified approach that is more compatible:
>
> * We always encode QStrings as utf8 (maybe utf16 for the windows console)
> when sending them to qDebug()
That would change behaviour for people with non-UTF-8 systems, as they'd now
see mojibake.
> * We quote every character that is not printable (ie. !QChar::isPrint())
This is what I've done, except that I used ctype.h's isprint(), under the "C"
locale. I considered using QChar::isPrint here, but it would be very expensive
and it would not solve the homograph and ambiguity problem anyway. Better to
just do nothing than use QChar::isPrint.
> * We add a flag that would give fully quoted strings so you can get a
> quoted version if required (e.g. qDebug() << quoteStrings)
I'm ok with a flag, as long as it's the default.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list