This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re:Patch to make XMLPrinter encoding-aware
- From: Дмитрий <dmymd at yandex dot ru>
- To: Per Bothner <per at bothner dot com>
- Cc: kawa at sources dot redhat dot com
- Date: Sun, 29 Jul 2012 02:36:52 +0400
- Subject: Re:Patch to make XMLPrinter encoding-aware
Hellp!
> * 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)?
Yes, surrogate pairs are exactly they reason why I've used CharSequence.
I believe a call to canEncode(new String(Character.toChars(v))) can be safely
replaced with
canEncode(new String(v <= 0xFFFF ? (char)v : Character.toChars(v)))
> setEscapeCharset(charset)
> is missing?
My bad. Yes, it is definitely 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.
Adding a special case for Unicode and ASCII seemed logical to me
since they are two extremes (encode nothing vs. encode everything).
Also, escapeNonAscii was declared public so I didn't dare delete it
anyway.
--
Yours sincerely,
Dmitry Kushnariov