[plt-scheme] Outputting accents

From: Paulo J. Matos (pocmatos at gmail.com)
Date: Wed May 10 10:21:20 EDT 2006

On 10/05/06, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> 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))))
>
>

Very nice, thanks.

Paulo Matos

> Matthew
>
>


--
Paulo Jorge Matos - pocm at sat inesc-id pt
Web: http://sat.inesc-id.pt/~pocm
Computer and Software Engineering
INESC-ID - SAT Group


Posted on the users mailing list.