diff options
Diffstat (limited to 'util/ttyio.c')
-rw-r--r-- | util/ttyio.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/util/ttyio.c b/util/ttyio.c index 35e0d318f..e2c1f8496 100644 --- a/util/ttyio.c +++ b/util/ttyio.c @@ -236,7 +236,7 @@ tty_print_string( byte *p, size_t n ) } void -tty_print_utf8_string( byte *p, size_t n ) +tty_print_utf8_string2( byte *p, size_t n, size_t max_n ) { size_t i; char *buf; @@ -251,15 +251,26 @@ tty_print_utf8_string( byte *p, size_t n ) } if( i < n ) { buf = utf8_to_native( p, n ); + if( strlen( buf ) > max_n ) { + buf[max_n] = 0; + } + /*(utf8 conversion already does the control character quoting)*/ tty_printf("%s", buf ); m_free( buf ); } - else + else { + if( n > max_n ) { + n = max_n; + } tty_print_string( p, n ); + } } - - +void +tty_print_utf8_string( byte *p, size_t n ) +{ + tty_print_utf8_string( p, n, n ) +} static char * |