mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Rewrite outputBits without sprintf (deprecated)
This commit is contained in:
parent
a8fba863a3
commit
38141ef655
1 changed files with 13 additions and 9 deletions
|
@ -183,19 +183,23 @@ void outputBits(unsigned char byte, QDebug* continuedDebug) {
|
|||
}
|
||||
|
||||
QString resultString;
|
||||
QTextStream qts (&resultString);
|
||||
|
||||
qts << "[ ";
|
||||
qts << qSetFieldWidth(3) << byte << qSetFieldWidth(0);
|
||||
qts << qSetPadChar('0');
|
||||
|
||||
if (isalnum(byte)) {
|
||||
resultString.sprintf("[ %d (%c): ", byte, byte);
|
||||
qts << " (" << QString(byte) << ") : ";
|
||||
} else {
|
||||
resultString.sprintf("[ %d (0x%x): ", byte, byte);
|
||||
qts << " (0x" << Qt::hex << qSetFieldWidth(2) << byte << qSetFieldWidth(0) << "): ";
|
||||
}
|
||||
debug << qPrintable(resultString);
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
resultString.sprintf("%d", byte >> (7 - i) & 1);
|
||||
debug << qPrintable(resultString);
|
||||
}
|
||||
debug << " ]";
|
||||
|
||||
qts << Qt::bin << qSetFieldWidth(8) << byte << qSetFieldWidth(0);
|
||||
qts << " ]";
|
||||
|
||||
debug.noquote();
|
||||
debug << resultString;
|
||||
}
|
||||
|
||||
int numberOfOnes(unsigned char byte) {
|
||||
|
|
Loading…
Reference in a new issue