This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re:Escaping of non-ASCII characters in XML
- From: Дмитрий <dmymd at yandex dot ru>
- To: Per Bothner <per at bothner dot com>
- Cc: kawa at sources dot redhat dot com
- Date: Tue, 24 Jul 2012 02:42:16 +0400
- Subject: Re:Escaping of non-ASCII characters in XML
Hello!
> Can you remind me where Kawa's internal HTTP server does the
> string-escaping?
gnu/kawa/xml/HttpPrinter.java (it still call the same XMLPrinter)
> It might make sense, but I'm a little uncomfortable with the idea that
> toString output is different from printing to a file. What you then
> print out the toString return to an ASCII or Latin-1-only file or terminal?
Hmm... Your approach seems reasonable.
It just occured to me that to have a normal XML it's not neccessary to
change internals, since I can rewrite toString as a normal function:
(define (print-xml node ::gnu.kawa.xml.KNode)
(letrec ((wr (gnu.mapping.CharArrayOutPort))
(xp (gnu.xml.XMLPrinter wr)))
(set! xp:escapeNonAscii #f)
(gnu.xml.NodeTree:consume-next node:sequence node:ipos xp)
(gnu.xml.XMLPrinter:close xp)
(gnu.mapping.CharArrayOutPort:close wr)
(gnu.mapping.CharArrayOutPort:to-string wr)))
So I guess I can have nice XML without any internal changes.
But the server encoding seems to be trickier, but I believe I can do with
wrapping my #<html> try in (unescaped-data ...).
---
Yours sincerely,
Dmitry Kushnariov
P.S. Speaking of Latin-1 terminals. (write "Ã") should ideally print
"\u00c6", not "?" it does now, since write strings are expected to
be read back...