From 9ef3ff30e1119ed61791eabe237758665e574060 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 17 Nov 2014 21:11:23 -0800 Subject: Add support for char16_t, char32_t and std::nullptr_t in QDebug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required before we can add support for those three types in QVariant. This commit changes the output format for QChar when it falls outside the printable ASCII range. In the future, it might be nice to use the pretty-printing of control characters like QtTest and QJsonDocument. Change-Id: I4d942da8d11f83de9c1b485ea6ca804fe1622602 Reviewed-by: Jędrzej Nowacki --- src/corelib/io/qdebug.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/corelib/io/qdebug.cpp') diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index c1e0125cb1..9eed1f352a 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -147,6 +147,28 @@ QDebug::~QDebug() } } +/*! + \internal +*/ +void QDebug::putUcs4(uint ucs4) +{ + maybeQuote('\''); + if (ucs4 < 0x20) { + stream->ts << hex << "\\x" << ucs4 << reset; + } else if (ucs4 < 0x80) { + stream->ts << char(ucs4); + } else { + stream->ts << hex << qSetPadChar(QLatin1Char('0')); + if (ucs4 < 0x10000) + stream->ts << qSetFieldWidth(4) << "\\u"; + else + stream->ts << qSetFieldWidth(8) << "\\U"; + stream->ts << ucs4 << reset; + } + maybeQuote('\''); +} + + /*! \fn QDebug::swap(QDebug &other) \since 5.0 -- cgit v1.2.3