mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bernd Fondermann <bf_...@brainlounge.de>
Subject Re: [VYSPER][nbxml] Non-ASCII chars get crippled
Date Mon, 24 Sep 2012 12:51:37 GMT
On Sun Sep 23 16:32:58 2012, Niklas Gustavsson wrote:
> 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?

not a dedicated unit test, but sending a chat message containing 
umlauts actually triggers this code.

  Bernd

Mime
View raw message