From 88a916cdd40e43312ffcde6bb1c157fe1c122f74 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 31 Aug 1999 15:30:12 +0000 Subject: See ChangeLog: Tue Aug 31 17:20:44 CEST 1999 Werner Koch --- util/miscutil.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'util/miscutil.c') diff --git a/util/miscutil.c b/util/miscutil.c index 2b95d97d6..eb72415bb 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -193,6 +193,29 @@ print_string( FILE *fp, const byte *p, size_t n, int delim ) putc(*p, fp); } +/**************** + * Print an UTF8 string to FP and filter all control characters out. + */ +void +print_utf8_string( FILE *fp, const byte *p, size_t n ) +{ + size_t i; + char *buf; + + /* we can handle plain ascii simpler, so check for it first */ + for(i=0; i < n; i++ ) { + if( p[i] & 0x80 ) + break; + } + if( i < n ) { + buf = utf8_to_native( p, n ); + fputs( buf, fp ); + m_free( buf ); + } + else + print_string( fp, p, n, 0 ); +} + /**************** * This function returns a string which is suitable for printing * Caller must release it with m_free() @@ -211,7 +234,7 @@ make_printable_string( const byte *p, size_t n, int delim ) || *p=='\v' || *p=='\b' || !*p ) buflen += 2; else - buflen += 3; + buflen += 4; } else buflen++; -- cgit