This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]