[plt-scheme] Outputting accents
At Wed, 10 May 2006 09:41:23 +0100, "Paulo J. Matos" wrote:
> I'm having a problem with accents. With webit, when I do:
> > (write-xml (h4:p "Olá"))
> <p>Olá</p>
>
> Everything shows up ok. However, when I do:
> > (with-output-to-file "/home/pmatos/xxx.txt" (lambda () (write-xml (h4:p
> "Olá"))))
>
> xxx.txt gets the wierd characters in place of "á".
By default, MzScheme writes strings in UTF-8. If you want Latin-1
output, then you could write something like
(require (lib "port.ss"))
(call-with-output-file "/tmp/xxx.txt"
(lambda (orig-p)
(let ([p (reencode-output-port orig-p "latin1")])
(write-xml (h4:p "Olá") p)
(flush-output p))))
Matthew