diff --git a/libguile/print.c b/libguile/print.c index 86e0a0367..a5b2a845b 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -1034,7 +1034,11 @@ display_string_using_iconv (const void *str, int narrow_p, size_t len, printed++; } - else + else if (errno_save == E2BIG) + /* No space in output buffer for this input. Keep + trucking. */ + continue; + else /* Something bad happened that we can't handle: bail out. */ break; } diff --git a/test-suite/tests/iconv.test b/test-suite/tests/iconv.test index 9083cd256..647761f04 100644 --- a/test-suite/tests/iconv.test +++ b/test-suite/tests/iconv.test @@ -118,3 +118,16 @@ (equal? (make-string (string-length s) #\?) (bytevector->string (string->bytevector s "ascii" 'substitute) "ascii"))))) + +(with-test-prefix "round-trip" + (define (pass-if-round-trip str encoding) + (pass-if-equal str str + (bytevector->string (string->bytevector str encoding) encoding))) + + (pass-if-round-trip (make-string 128 #\a) "UTF-8") + (pass-if-round-trip (make-string 128 #\a) "UTF-16") + (pass-if-round-trip (make-string 128 #\a) "UTF-32") + + (pass-if-round-trip (make-string 129 #\a) "UTF-8") + (pass-if-round-trip (make-string 129 #\a) "UTF-16") + (pass-if-round-trip (make-string 129 #\a) "UTF-32"))