From 1716f9e7cd28b95d803cded809269c018ff55c81 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 23 May 2019 18:41:07 -0700 Subject: [PATCH] fix our ostream << hex << char Even when hex modifier is used, 'char' should be printed as characters, this is particularly relevant with 0. e.g. out << (char)0, should write a nul terminator, not "0". --- libs/utils/src/ostream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/utils/src/ostream.cpp b/libs/utils/src/ostream.cpp index 44b6f04f69..15c80fc250 100644 --- a/libs/utils/src/ostream.cpp +++ b/libs/utils/src/ostream.cpp @@ -73,8 +73,8 @@ const char* ostream::getFormat(ostream::type t) const noexcept { switch (t) { case type::SHORT: return mShowHex ? "0x%hx" : "%hd"; case type::USHORT: return mShowHex ? "0x%hx" : "%hu"; - case type::CHAR: return mShowHex ? "0x%x" : "%c"; - case type::UCHAR: return mShowHex ? "0x%x" : "%c"; + case type::CHAR: return "%c"; + case type::UCHAR: return "%c"; case type::INT: return mShowHex ? "0x%x" : "%d"; case type::UINT: return mShowHex ? "0x%x" : "%u"; case type::LONG: return mShowHex ? "0x%lx" : "%ld";