diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2018-05-09 10:14:47 +0200 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2018-05-09 09:33:24 +0000 |
commit | bba0041bfdea0c64acbf1945e215737a394de4e8 (patch) | |
tree | ed0b6a007de2cd994f4fd7b06206880efb83e76d /ui/qt | |
parent | a1f95b64581168e3fcf202c27985dc7e99a429a9 (diff) |
Qt: Add Show as UTF-16 in Show Packet Bytes
Change-Id: Ia7c7af162ac0010e2a5b83caf1ac467012432567
Reviewed-on: https://code.wireshark.org/review/27420
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/show_packet_bytes_dialog.cpp | 13 | ||||
-rw-r--r-- | ui/qt/show_packet_bytes_dialog.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/ui/qt/show_packet_bytes_dialog.cpp b/ui/qt/show_packet_bytes_dialog.cpp index b506513f2a..ef9aea5f25 100644 --- a/ui/qt/show_packet_bytes_dialog.cpp +++ b/ui/qt/show_packet_bytes_dialog.cpp @@ -73,6 +73,7 @@ ShowPacketBytesDialog::ShowPacketBytesDialog(QWidget &parent, CaptureFile &cf) : ui->cbShowAs->addItem(tr("ISO 8859-1"), ShowAsISO8859_1); ui->cbShowAs->addItem(tr("Raw"), ShowAsRAW); ui->cbShowAs->addItem(tr("UTF-8"), ShowAsUTF8); + ui->cbShowAs->addItem(tr("UTF-16"), ShowAsUTF16); ui->cbShowAs->addItem(tr("YAML"), ShowAsYAML); ui->cbShowAs->setCurrentIndex(show_as_); ui->cbShowAs->blockSignals(false); @@ -283,6 +284,7 @@ void ShowPacketBytesDialog::copyBytes() break; case ShowAsUTF8: + case ShowAsUTF16: wsApp->clipboard()->setText(ui->tePacketBytes->toPlainText().toUtf8()); break; } @@ -328,6 +330,7 @@ void ShowPacketBytesDialog::saveAs() } case ShowAsUTF8: + case ShowAsUTF16: { QTextStream out(&file); out << ui->tePacketBytes->toPlainText().toUtf8(); @@ -704,6 +707,16 @@ void ShowPacketBytesDialog::updatePacketBytes(void) break; } + case ShowAsUTF16: + { + // QString::fromUtf16 calls QUtf16::convertToUnicode, casting buffer + // back to a const char * and doubling nchars. + QString utf16 = QString::fromUtf16((const unsigned short *)field_bytes_.constData(), (int)field_bytes_.length() / 2); + ui->tePacketBytes->setLineWrapMode(QTextEdit::WidgetWidth); + ui->tePacketBytes->setPlainText(utf16); + break; + } + case ShowAsYAML: { const int base64_raw_len = 57; // Encodes to 76 bytes, common in RFCs diff --git a/ui/qt/show_packet_bytes_dialog.h b/ui/qt/show_packet_bytes_dialog.h index 7db4807e47..6de5fadad8 100644 --- a/ui/qt/show_packet_bytes_dialog.h +++ b/ui/qt/show_packet_bytes_dialog.h @@ -81,6 +81,7 @@ private: ShowAsISO8859_1, ShowAsRAW, ShowAsUTF8, + ShowAsUTF16, ShowAsYAML }; |