mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-29 14:30:34 +02:00
Fix iconv encoding of long strings
* libguile/print.c (display_string_using_iconv): If the encoding the full utf8 buffer would overflow the output buffer, just keep trucking instead of erroring. Fixes #22667. * test-suite/tests/iconv.test ("round-trip"): Add some tests.
This commit is contained in:
parent
f9f438d471
commit
681acfd8ba
2 changed files with 18 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue