diff --git a/epan/follow.h b/epan/follow.h index 2c9d237b9f..00d26fc763 100644 --- a/epan/follow.h +++ b/epan/follow.h @@ -63,7 +63,8 @@ typedef enum { SHOW_CARRAY, SHOW_RAW, SHOW_YAML, - SHOW_UTF8 + SHOW_UTF8, + SHOW_UTF16 } show_type_t; diff --git a/ui/gtk/follow_stream.c b/ui/gtk/follow_stream.c index d68f15ebb6..d12a6234c0 100644 --- a/ui/gtk/follow_stream.c +++ b/ui/gtk/follow_stream.c @@ -1194,6 +1194,7 @@ follow_show(follow_info_t *follow_info, case SHOW_YAML: case SHOW_UTF8: + case SHOW_UTF16: g_assert_not_reached(); break; } diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index 2cbd62575c..4da52e5fd3 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -116,6 +116,7 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_ cbcs->addItem(tr("EBCDIC"), SHOW_EBCDIC); cbcs->addItem(tr("Hex Dump"), SHOW_HEXDUMP); cbcs->addItem(tr("UTF-8"), SHOW_UTF8); + cbcs->addItem(tr("UTF-16"), SHOW_UTF16); cbcs->addItem(tr("YAML"), SHOW_YAML); cbcs->addItem(tr("Raw"), SHOW_RAW); cbcs->blockSignals(false); @@ -638,7 +639,7 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser break; } - case SHOW_UTF8: // UTF-8 + case SHOW_UTF8: { // The QString docs say that invalid characters will be replaced with // replacement characters or removed. It would be nice if we could @@ -648,6 +649,15 @@ FollowStreamDialog::showBuffer(char *buffer, size_t nchars, gboolean is_from_ser break; } + case SHOW_UTF16: + { + // QString::fromUtf16 calls QUtf16::convertToUnicode, casting buffer + // back to a const char * and doubling nchars. + QString utf16 = QString::fromUtf16((const unsigned short *)buffer, (int)nchars / 2); + addText(utf16, is_from_server, packet_num); + break; + } + case SHOW_HEXDUMP: current_pos = 0; while (current_pos < nchars) {