diff options
author | Werner Koch <[email protected]> | 1999-08-31 15:30:12 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 1999-08-31 15:30:12 +0000 |
commit | 88a916cdd40e43312ffcde6bb1c157fe1c122f74 (patch) | |
tree | d5298986a0bad2aff797fd981f99fb3cb6f99ba9 /util/miscutil.c | |
parent | See ChangeLog: Mon Aug 30 20:38:33 CEST 1999 Werner Koch (diff) | |
download | gnupg-88a916cdd40e43312ffcde6bb1c157fe1c122f74.tar.gz gnupg-88a916cdd40e43312ffcde6bb1c157fe1c122f74.zip |
See ChangeLog: Tue Aug 31 17:20:44 CEST 1999 Werner Koch
Diffstat (limited to 'util/miscutil.c')
-rw-r--r-- | util/miscutil.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/util/miscutil.c b/util/miscutil.c index 2b95d97d6..eb72415bb 100644 --- a/util/miscutil.c +++ b/util/miscutil.c @@ -194,6 +194,29 @@ print_string( FILE *fp, const byte *p, size_t n, int delim ) } /**************** + * 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++; |