[Development] Prettier printing of Unicode strings
Thiago Macieira
thiago.macieira at intel.com
Tue Jan 21 01:05:07 CET 2014
I was writing a test today and QtTest told me:
Actual (s) : ?12???
Expected (s2): ?12???
So I went, "duh, ok, it looks the same to me but what's behind those question
marks".
After a bit of changes [https://codereview.qt-project.org/76100], it now
prints:
Actual (s) : \u221212\u20A0\uD800\uDC00
Expected (s2): \u221212\u20AC\uD800\uDC00
Which tells me what I got wrong.
Ok to submit this change then? It will make all toString(QString) print
- all backslashes as \\
- the following characters as their escape sequences: \r, \n, \t, \b, \f
- all other control characters (including 0x7f) as \u00XX
- all other characters with \uXXXX, including text otherwise readable in the
terminal in the locale
One major advantage of this is that it does not depend on the locale codec
being set up or even working, as the previous code did. So we get consistent
results even if there's a bug in that.
Is this ok?
Should I also print quotes as \" ? And should I surround the string with
quotes?
Should I also do the same for QByteArray? Reading hex dumps isn't very nice.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140120/062b5c46/attachment.sig>
More information about the Development
mailing list