Add 8th byte padding

This commit is contained in:
Alex Spataru 2025-01-07 22:17:34 -05:00
parent e436b40d56
commit 5054ab3ec5

View File

@ -590,25 +590,32 @@ QString IO::Console::hexadecimalStr(const QByteArray &data)
for (int i = 0; i < data.length(); i += rowSize) for (int i = 0; i < data.length(); i += rowSize)
{ {
// Add offset to output // Add offset to output
out += QStringLiteral("0x%1: ").arg(i, 6, 16, QLatin1Char('0')); out += QStringLiteral("%1 | ").arg(i, 6, 16, QLatin1Char('0'));
// Print hexadecimal bytes // Print hexadecimal bytes
for (int j = 0; j < rowSize; ++j) for (int j = 0; j < rowSize; ++j)
{ {
// Print existing data
if (i + j < data.length()) if (i + j < data.length())
{ {
out += QStringLiteral("%1 ").arg( out += QStringLiteral("%1 ").arg(
static_cast<unsigned char>(data[i + j]), 2, 16, QLatin1Char('0')); static_cast<unsigned char>(data[i + j]), 2, 16, QLatin1Char('0'));
} }
// Space out inexistent data
else else
out += QStringLiteral(" "); out += QStringLiteral(" ");
// Add padding in 8th byte
if ((j + 1) == 8)
out += ' ';
} }
// Add ASCII representation // Add ASCII representation
out += QStringLiteral(" | "); out += QStringLiteral("| ");
for (int j = 0; j < rowSize; ++j) for (int j = 0; j < rowSize; ++j)
{ {
// Add existing data
if (i + j < data.length()) if (i + j < data.length())
{ {
char c = data[i + j]; char c = data[i + j];
@ -617,10 +624,14 @@ QString IO::Console::hexadecimalStr(const QByteArray &data)
else else
out += '.'; out += '.';
} }
// Add space for inexisting data
else
out += ' ';
} }
// Add line break // Add line break
out += "\n"; out += QStringLiteral(" |\n");
} }
// Add additional line break & return data // Add additional line break & return data