Rewrite outputBits without sprintf (deprecated)

This commit is contained in:
Dale Glass 2022-06-05 13:02:14 +02:00
parent a8fba863a3
commit 38141ef655

View file

@ -183,19 +183,23 @@ void outputBits(unsigned char byte, QDebug* continuedDebug) {
} }
QString resultString; QString resultString;
QTextStream qts (&resultString);
qts << "[ ";
qts << qSetFieldWidth(3) << byte << qSetFieldWidth(0);
qts << qSetPadChar('0');
if (isalnum(byte)) { if (isalnum(byte)) {
resultString.sprintf("[ %d (%c): ", byte, byte); qts << " (" << QString(byte) << ") : ";
} else { } else {
resultString.sprintf("[ %d (0x%x): ", byte, byte); qts << " (0x" << Qt::hex << qSetFieldWidth(2) << byte << qSetFieldWidth(0) << "): ";
} }
debug << qPrintable(resultString);
qts << Qt::bin << qSetFieldWidth(8) << byte << qSetFieldWidth(0);
for (int i = 0; i < 8; i++) { qts << " ]";
resultString.sprintf("%d", byte >> (7 - i) & 1);
debug << qPrintable(resultString); debug.noquote();
} debug << resultString;
debug << " ]";
} }
int numberOfOnes(unsigned char byte) { int numberOfOnes(unsigned char byte) {