mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Gustavsson <nik...@protocol7.com>
Subject Re: [VYSPER][nbxml] Non-ASCII chars get crippled
Date Sun, 23 Sep 2012 14:32:58 GMT
On Sun, Sep 23, 2012 at 9:47 AM, Bernd Fondermann
<bernd.fondermann@gmail.com> 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?


View raw message