aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/show_packet_bytes_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/show_packet_bytes_dialog.cpp')
-rw-r--r--ui/qt/show_packet_bytes_dialog.cpp13
1 files changed, 13 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