diff options
author | Guy Harris <gharris@sonic.net> | 2022-10-21 00:42:42 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2022-10-21 00:42:42 -0700 |
commit | 10703285972f0e992e25409667464d302c949304 (patch) | |
tree | 3197fae5b891adb7d6a6f93be0f1785f78249646 /ui/qt | |
parent | de50666ec077a0b09f3d61ccd20870a03db52c92 (diff) |
packet bytes: do a simpler test for "is this ASCII?"
Just test whether the octet has the 0x80 bit set.
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/show_packet_bytes_dialog.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ui/qt/show_packet_bytes_dialog.cpp b/ui/qt/show_packet_bytes_dialog.cpp index 5f75f9dd9a..4c42686187 100644 --- a/ui/qt/show_packet_bytes_dialog.cpp +++ b/ui/qt/show_packet_bytes_dialog.cpp @@ -470,10 +470,15 @@ void ShowPacketBytesDialog::sanitizeBuffer(QByteArray &ba, bool keep_CR) void ShowPacketBytesDialog::symbolizeBuffer(QByteArray &ba) { - // Replace all characters that aren't printable ASCII or ASCII - // control characters with MIDDLE DOT. + // Replace all octets that don't correspond to an ASCII + // character with MIDDLE DOT. An octet corresponds to an + // ASCII character iff the 0x80 bit isn't set in its + // value; if char is signed (which it is *not* guaranteed + // to be; it is, for example, unsigned on non-Apple ARM + // platforms), sign-extension won't affect that bit, so + // simply testing the 0x80 bit suffices on all platforms. for (int i = 0; i < ba.length(); i++) { - if (!g_ascii_isprint(ba[i]) && !g_ascii_iscntrl(ba[i])) { + if (ba[i] & 0x80) { ba.replace(i, 1, UTF8_MIDDLE_DOT); i += sizeof(UTF8_MIDDLE_DOT) - 2; } |