diff options
Diffstat (limited to 'module/rnrs')
-rw-r--r-- | module/rnrs/io/ports.scm | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/module/rnrs/io/ports.scm b/module/rnrs/io/ports.scm index c1484cbed..2968dbd9f 100644 --- a/module/rnrs/io/ports.scm +++ b/module/rnrs/io/ports.scm @@ -220,24 +220,22 @@ (define (port-transcoder port) "Return the transcoder object associated with @var{port}, or @code{#f} if the port has no transcoder." - (cond ((port-encoding port) - => (lambda (encoding) - (make-transcoder - encoding - (native-eol-style) - (case (port-conversion-strategy port) - ((error) 'raise) - ((substitute) 'replace) - (else - (assertion-violation 'port-transcoder - "unsupported error handling mode")))))) - (else - #f))) + (and (textual-port? port) + ;; All textual ports have transcoders. + (make-transcoder + (port-encoding port) + (native-eol-style) + (case (port-conversion-strategy port) + ((error) 'raise) + ((substitute) 'replace) + (else + (assertion-violation 'port-transcoder + "unsupported error handling mode")))))) (define (binary-port? port) - "Returns @code{#t} if @var{port} does not have an associated encoding, -@code{#f} otherwise." - (not (port-encoding port))) + "Always returns @code{#t}, as all ports can be used for binary I/O in +Guile." + (equal? (port-encoding port) "ISO-8859-1")) (define (textual-port? port) "Always returns @code{#t}, as all ports can be used for textual I/O in @@ -305,8 +303,7 @@ read from/written to in @var{port}." (define (open-string-input-port str) "Open an input port that will read from @var{str}." - (with-fluids ((%default-port-encoding "UTF-8")) - (open-input-string str))) + (open-input-string str)) (define (r6rs-open filename mode buffer-mode transcoder) (let ((port (with-i/o-filename-conditions filename @@ -351,8 +348,7 @@ read from/written to in @var{port}." (define (open-string-output-port) "Return two values: an output port that will collect characters written to it as a string, and a thunk to retrieve the characters associated with that port." - (let ((port (with-fluids ((%default-port-encoding "UTF-8")) - (open-output-string)))) + (let ((port (open-output-string))) (values port (lambda () (get-output-string port))))) |