forked from osmocom/wireshark
TShark: Add a "-E bom=" option.
Add an option to print the UTF-8 BOM. Change-Id: I3d30c67852b9b89d1548b0f957d97fd8e8741049 Reviewed-on: https://code.wireshark.org/review/15318 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
bca12baa4c
commit
d7cbea9428
|
@ -309,6 +309,9 @@ selected.
|
|||
|
||||
Options are:
|
||||
|
||||
B<bom=y|n> If B<y>, prepend output with the UTF-8 byte order mark
|
||||
(hexadecimal ef, bb, bf). Defaults to B<n>.
|
||||
|
||||
B<header=y|n> If B<y>, print a list of the field names given using B<-e>
|
||||
as the first line of the output; the field name will be separated using
|
||||
the same character as the field values. Defaults to B<n>.
|
||||
|
|
21
epan/print.c
21
epan/print.c
|
@ -68,6 +68,7 @@ typedef struct {
|
|||
} write_field_data_t;
|
||||
|
||||
struct _output_fields {
|
||||
gboolean print_bom;
|
||||
gboolean print_header;
|
||||
gchar separator;
|
||||
gchar occurrence;
|
||||
|
@ -1199,6 +1200,19 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
else if (0 == strcmp(option_name, "bom")) {
|
||||
switch (*option_value) {
|
||||
case 'n':
|
||||
info->print_bom = FALSE;
|
||||
break;
|
||||
case 'y':
|
||||
info->print_bom = TRUE;
|
||||
break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1206,6 +1220,7 @@ gboolean output_fields_set_option(output_fields_t *info, gchar *option)
|
|||
void output_fields_list_options(FILE *fh)
|
||||
{
|
||||
fprintf(fh, "TShark: The available options for field output \"E\" are:\n");
|
||||
fputs("bom=y|n Prepend output with the UTF-8 BOM (def: N: no)\n", fh);
|
||||
fputs("header=y|n Print field abbreviations as first line of output (def: N: no)\n", fh);
|
||||
fputs("separator=/t|/s|<character> Set the separator to use;\n \"/t\" = tab, \"/s\" = space (def: /t: tab)\n", fh);
|
||||
fputs("occurrence=f|l|a Select the occurrence of a field to use;\n \"f\" = first, \"l\" = last, \"a\" = all (def: a: all)\n", fh);
|
||||
|
@ -1227,6 +1242,11 @@ void write_fields_preamble(output_fields_t* fields, FILE *fh)
|
|||
g_assert(fh);
|
||||
g_assert(fields->fields);
|
||||
|
||||
if (fields->print_bom) {
|
||||
fputs(UTF8_BOM, fh);
|
||||
}
|
||||
|
||||
|
||||
if (!fields->print_header) {
|
||||
return;
|
||||
}
|
||||
|
@ -1491,6 +1511,7 @@ get_field_hex_value(GSList *src_list, field_info *fi)
|
|||
output_fields_t* output_fields_new(void)
|
||||
{
|
||||
output_fields_t* fields = g_new(output_fields_t, 1);
|
||||
fields->print_bom = FALSE;
|
||||
fields->print_header = FALSE;
|
||||
fields->separator = '\t';
|
||||
fields->occurrence = 'a';
|
||||
|
|
1
tshark.c
1
tshark.c
|
@ -377,6 +377,7 @@ print_usage(FILE *output)
|
|||
fprintf(output, " _ws.col.Info)\n");
|
||||
fprintf(output, " this option can be repeated to print multiple fields\n");
|
||||
fprintf(output, " -E<fieldsoption>=<value> set options for output when -Tfields selected:\n");
|
||||
fprintf(output, " bom=y|n print a UTF-8 BOM\n");
|
||||
fprintf(output, " header=y|n switch headers on and off\n");
|
||||
fprintf(output, " separator=/t|/s|<char> select tab, space, printable character as separator\n");
|
||||
fprintf(output, " occurrence=f|l|a print first, last or all occurrences of each field\n");
|
||||
|
|
|
@ -58,6 +58,9 @@
|
|||
#define UTF8_BALLOT_X "\xe2\x9c\x97" /* 10007 / 0x2717 */
|
||||
#define UTF8_LONG_RIGHTWARDS_ARROW "\xe2\x9f\xb6" /* 10230 / 0x27f6 */
|
||||
|
||||
#define UTF8_ZERO_WIDTH_NO_BREAK_SPACE "\xef\xbb\xbf" /* 65279 / 0xffef */
|
||||
#define UTF8_BOM UTF8_ZERO_WIDTH_NO_BREAK_SPACE
|
||||
|
||||
#endif /* __UTF8_ENTITIES_H__ */
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue