summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/tshark.pod3
-rw-r--r--epan/print.c21
-rw-r--r--tshark.c1
-rw-r--r--wsutil/utf8_entities.h3
4 files changed, 28 insertions, 0 deletions
diff --git a/doc/tshark.pod b/doc/tshark.pod
index 7a82d6c061..70ec28d372 100644
--- a/doc/tshark.pod
+++ b/doc/tshark.pod
@@ -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>.
diff --git a/epan/print.c b/epan/print.c
index 6f8a7592e0..e657324c06 100644
--- a/epan/print.c
+++ b/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';
diff --git a/tshark.c b/tshark.c
index 8d0dc03303..90361903a3 100644
--- a/tshark.c
+++ b/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");
diff --git a/wsutil/utf8_entities.h b/wsutil/utf8_entities.h
index 13dba64270..6cb06e1f86 100644
--- a/wsutil/utf8_entities.h
+++ b/wsutil/utf8_entities.h
@@ -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__ */
/*