On Sun, Sep 23, 2012 at 9:47 AM, Bernd Fondermann <[email protected]> wrote: > This is a first shot from me at it: > Replacing all > buffer.put((byte) c); > by > protected void putChar(char c) { > if ((c & 0xff00) != 0) { > final byte shifted = (byte)(((int)c) >> 8); > buffer.put(shifted); > } > buffer.put((byte)c); > } > > which breaks unit tests and leads to exceptions later. I had no time > to investigate further.
I had a look at it now. While the (byte) c code looks weird, it's not really wrong, since we a bit up read out a byte and cast that to char (so your if should never evaluate). Of course, these both casts are not needed and I'm about to commit a change which cleans up this code a bit. Also, I've failed to reproduce any problems with multi-byte Unicode chars (we already had a few test cases for them, and I've strengthen a bit further), do you have a test case which fails that would help me find the problem? /niklas
