From 8b19f0c3c0171263285540c730abbb68d33895dc Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 11 Jan 2021 00:34:50 +0100 Subject: [PATCH] Improved UTF-8 display in data inspector --- source/views/view_data_inspector.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/views/view_data_inspector.cpp b/source/views/view_data_inspector.cpp index 4256ce6f9..0537ef9f3 100644 --- a/source/views/view_data_inspector.cpp +++ b/source/views/view_data_inspector.cpp @@ -87,7 +87,11 @@ namespace hex { u8 codepointSize = ImTextCharFromUtf8(&codepoint, buffer, buffer + 4); std::memcpy(codepointString, &codepoint, std::min(codepointSize, u8(4))); - this->m_cachedData.emplace_back("UTF-8 code point", hex::format("'%s' (U+%04lx)", codepoint == 0xFFFD ? "Invalid" : codepointString, codepoint), sizeof(char8_t)); + this->m_cachedData.emplace_back("UTF-8 code point", hex::format("'%s' (U+%04lx)", + codepoint == 0xFFFD ? "Invalid" : + codepoint < 0xFF ? makePrintable(codepoint).c_str() : + codepointString + , codepoint), sizeof(char8_t)); } this->m_cachedData.emplace_back("float (32 bit)", hex::format("%e", hex::changeEndianess(this->m_previewData.float32, this->m_endian)), sizeof(float));