diff --git a/pkgs/gui-pkgs/gui-lib/framework/private/text.rkt b/pkgs/gui-pkgs/gui-lib/framework/private/text.rkt index 224c72d24a..24b58468d8 100644 --- a/pkgs/gui-pkgs/gui-lib/framework/private/text.rkt +++ b/pkgs/gui-pkgs/gui-lib/framework/private/text.rkt @@ -2893,7 +2893,7 @@ [else (define leftovers (subbytes the-bytes src-read-amt (bytes-length the-bytes))) (at-enqueue (cons leftovers key) remainder-re-enqueued)])) - (define converted-str (bytes->string/utf-8 (subbytes the-bytes 0 src-read-amt))) + (define converted-str (bytes->string/utf-8 converted-bytes)) (values (reverse (cons (cons converted-str key) acc)) new-at-queue too-many-bytes?)] diff --git a/pkgs/gui-pkgs/gui-test/framework/tests/text.rkt b/pkgs/gui-pkgs/gui-test/framework/tests/text.rkt index 5683624229..33651486ad 100644 --- a/pkgs/gui-pkgs/gui-test/framework/tests/text.rkt +++ b/pkgs/gui-pkgs/gui-test/framework/tests/text.rkt @@ -397,6 +397,25 @@ (void (write-bytes ,(subbytes bts 1 (bytes-length bts)) p)) (flush-output p) (send t get-text)))))) + + (let ([b (bytes 195 195 (char->integer #\a))]) + (test + 'text:ports%.broken-encoding + (λ (x) + (define c (bytes-open-converter "UTF-8-permissive" "UTF-8")) + (define-values (result-bytes src-read-amt termination) (bytes-convert c b)) + (equal? x (bytes->string/utf-8 result-bytes))) + (λ () + (queue-sexp-to-mred + `(let () + (define t (new (text:ports-mixin text:wide-snip%))) + (define p (send t get-out-port)) + (yield + (thread + (λ () + (write-bytes ,b p) + (flush-output p)))) + (send t get-text)))))) ;; the next tests test the interaction when the current