[plt-scheme] encoding: latin1 and utf

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun May 1 01:11:37 EDT 2005

At Sat, 30 Apr 2005 21:53:02 -0700, Matthew Flatt wrote:
>  (require (lib "port.ss"))
>  (current-input-port
>   (reencode-input-port (current-input-port) "" #"?" #t))
>  (let ([re-out (lambda (port buffer-mode)
>                  (reencode-output-port port "" #"?" #t 
>                   (object-name port) buffer-mode))])
>    (current-output-port (re-out (current-output-port) 'line))
>    (current-error-port (re-out (current-error-port) 'none)))

I changed the default buffer mode for output reencoding to be the
result of `file-stream-buffer-mode'. So, when the current output ports
are file-stream ports, here's a better version:

 (require (lib "port.ss"))
 (let ([re (lambda (param reencode)
             (param (reencode (param) "" #"?" #t)))])
   (re current-input-port reencode-input-port)
   (re current-output-port reencode-output-port)
   (re current-error-port reencode-output-port))


Posted on the users mailing list.