diff --git a/Source/Common/MemoryCommon.cpp b/Source/Common/MemoryCommon.cpp index 7e40ff04..75acea95 100644 --- a/Source/Common/MemoryCommon.cpp +++ b/Source/Common/MemoryCommon.cpp @@ -1,5 +1,6 @@ #include "MemoryCommon.h" +#include #include #include #include @@ -624,13 +625,23 @@ std::string formatMemoryToString(const char* memory, const MemType type, const s } case Common::MemType::type_string: { - int actualLength = 0; - for (actualLength; actualLength < length; ++actualLength) + std::string text; + for (std::string::size_type i{0}; i < length; ++i) { - if (*(memory + actualLength) == 0x00) + const char c{memory[i]}; + if (c == '\0') break; + + if (std::isprint(c)) + { + text.push_back(c); + } + else + { + text += "�"; + } } - return std::string(memory, actualLength); + return text; } case Common::MemType::type_byteArray: { diff --git a/Source/MemoryScanner/MemoryScanner.cpp b/Source/MemoryScanner/MemoryScanner.cpp index c7816ca2..c3f7f45c 100644 --- a/Source/MemoryScanner/MemoryScanner.cpp +++ b/Source/MemoryScanner/MemoryScanner.cpp @@ -501,7 +501,8 @@ std::string MemScanner::getFormattedScannedValueAt(const int index) const bool aramAccessible = DolphinComm::DolphinAccessor::isARAMAccessible(); u32 offset = Common::dolphinAddrToOffset(m_resultsConsoleAddr.at(index), aramAccessible); u32 ramIndex = Common::offsetToCacheIndex(offset, aramAccessible); - return Common::formatMemoryToString(&m_scanRAMCache[ramIndex], m_memType, m_memSize, m_memBase, + const size_t length{m_memType == Common::MemType::type_string ? ~0ULL : m_memSize}; + return Common::formatMemoryToString(&m_scanRAMCache[ramIndex], m_memType, length, m_memBase, !m_memIsSigned, Common::shouldBeBSwappedForType(m_memType)); }