Qt: Add UTF-16 output to Follow Stream.

Add an option to display the "follow" data as UTF-16.

Bug: 237
Change-Id: Id95ffc014b8ef718f3b6e9f3415806ada309c3a2
Reviewed-on: https://code.wireshark.org/review/15702
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2016-06-02 11:44:11 -07:00
parent 798360422b
commit bec5fed8b3
3 changed files with 14 additions and 2 deletions

View File

@ -63,7 +63,8 @@ typedef enum {
SHOW_CARRAY,
SHOW_RAW,
SHOW_YAML,
SHOW_UTF8
SHOW_UTF8,
SHOW_UTF16
} show_type_t;

View File

@ -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;
}

View File

@ -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) {