This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

port-char-encoding not working with call-with-output-file


Hi,

it looks like port-char-encoding is not fully functional (anymore?), at least
as far as call-with-output-file is concerned.

(define csv-stream #f)
(define (csv-log! filename) ;works: "UTF-16" "UTF-8"
  (set! csv-stream (fluid-let ((port-char-encoding "UTF-8"))
		     (open-output-file filename))))
(csv-log! "Umlaute")
(write "aou?AOU" csv-stream)
(define (csv-close!)
  (cond (csv-stream (close-output-port csv-stream) (set! csv-stream #f))))
(csv-close!)

; now let's compare with
(fluid-let ((port-char-encoding "UTF-8"))
  (call-with-output-file "Umlaute2"
    (lambda (port) (write "aouAOU" port))))
;; nevertheless uses ISO-8859-1 (or 15?)
M-x find-file-literally ---> iso-8859-1 (or -15), no UTF

I'd have expected this variable to work with all Kawa/Scheme file openers.

A possible(?) patch:
(define (call-with-output-file pathname proc)
  (let ((port (open-output-file pathname)))
    (try-finally
     (proc port)
     (close-output-port port))))

Regards,
	Jorg Hohle

Using Kawa-1.7 on Suse-Linux-9


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]