GNU bug report logs -
#22901
drain-input doesn't decode
Previous Next
Reported by: Zefram <zefram <at> fysh.org>
Date: Fri, 4 Mar 2016 03:11:01 UTC
Severity: normal
Done: Taylan Kammer <taylan.kammer <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Fri 04 Mar 2016 04:09, Zefram <zefram <at> fysh.org> writes:
> The documentation for drain-input says that it returns a string of
> characters, implying that the result is equivalent to what you'd get
> from calling read-char some number of times. In fact it differs in a
> significant respect: whereas read-char decodes input octets according to
> the port's selected encoding, drain-input ignores the selected encoding
> and always decodes according to ISO-8859-1 (thus preserving the octet
> values in character form).
>
> $ echo -n $'\1a\2b\3c' | guile-2.0 -c '(set-port-encoding!
> (current-input-port) "UCS-2BE") (write (port-encoding
> (current-input-port))) (newline) (write (map char->integer (let r ((l
> '\''())) (let ((c (read-char (current-input-port)))) (if (eof-object?
> c) (reverse l) (r (cons c l))))))) (newline)'
> "UCS-2BE"
> (353 610 867)
> $ echo -n $'\1a\2b\3c' | guile-2.0 -c '(set-port-encoding!
> (current-input-port) "UCS-2BE") (write (port-encoding
> (current-input-port))) (newline) (peek-char (current-input-port))
> (write (map char->integer (string->list (drain-input
> (current-input-port))))) (newline)'
> "UCS-2BE"
> (1 97 2 98 3 99)
Thanks for the test case! FWIW, this is fixed in Guile 2.1.3. I am not
sure what we should do about Guile 2.0. I guess we should make it do
the documented thing though!
Andy
This bug report was last modified 4 years ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.