Escaping of non-ASCII characters in XML
Дмитрий
dmymd@yandex.ru
Mon Jul 23 22:42:00 GMT 2012
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...
More information about the Kawa
mailing list