Patch to make XMLPrinter encoding-aware
Per Bothner
per@bothner.com
Sat Jul 28 21:47:00 GMT 2012
On 07/27/2012 12:03 PM, ÐмиÑÑий wrote:
> Hello!
>
> I've extended XMLPrinter with a field escapeCharsetEncoder ::java.nio.charset.CharsetEncoder and 2 methods:
> * method (gnu.xml.XMLPrinter:setEscapeCharset printer charset), accepts string or java.nio.charset.Charset as the 2nd argument
> * method (gnu.xml.XMLPrinter:setDefaultEscapeCharset printer), the same as above but uses the system charset
Thanks! Some questions/issues:
* In mustHexEscape, why do you use
escapeCharsetEncoder.canEncode(Charsequence)
rather than escapeCharsetEncoder.canEncode(char)? Presumably using the
latter
would be less expensive. Perhaps you canEncode(Charsequence) only if (v
> 0xFFFF)?
* setEscapeCharset(String charsetName) seems wrong - it doesn't actually use
the charset.
I assume a call to:
setEscapeCharset(charset)
is missing?
* I notice in setEscapeCharset(Charset charset) you don't actually save the
charset for certain well-known charsets. I guess that's a reasonable
optimization,
at the cost of a slight extra complexity, but I have to think about it.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
More information about the Kawa
mailing list