From fa1027a0048c1de11cb01dfdded3a88595a4a8c9 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Sat, 12 Oct 2013 12:38:56 +0000 Subject: From RobiOneKenobi via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9229 Add a new strutil function format_text_chr that replaces unprintable characters with a single passed-in char (eg a '.' or a '-') instead of a C-style escape. This is useful for displaying binary data that frequently but not always contains text; otherwise the number of C escape codes makes it unreadable. svn path=/trunk/; revision=52563 --- epan/strutil.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'epan/strutil.h') diff --git a/epan/strutil.h b/epan/strutil.h index 255993da65..7eacb67fe8 100644 --- a/epan/strutil.h +++ b/epan/strutil.h @@ -86,6 +86,22 @@ gchar* format_text(const guchar *line, size_t len); WS_DLL_PUBLIC gchar* format_text_wsp(const guchar *line, size_t len); +/* + * Given a string, generate a string from it that shows non-printable + * characters as the chr parameter passed, except a whitespace character + * (space, tab, carriage return, new line, vertical tab, or formfeed) + * which will be replaced by a space, and return a pointer to it. + * + * @param line A pointer to the input string + * @param len The length of the input string + * @param chr The character to use to replace non-printable characters + * @return A pointer to the formatted string + * + */ +WS_DLL_PUBLIC +gchar* format_text_chr(const guchar *string, const size_t len, const guchar chr); + + /** Turn an array of bytes into a string showing the bytes in hex. * * @param bd A pointer to the byte array -- cgit v1.2.3