classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cp-patches] RFC: patch for Unicode scalar value to UTF-16conversion


From: Jeroen Frijters
Subject: RE: [cp-patches] RFC: patch for Unicode scalar value to UTF-16conversion
Date: Sun, 8 Jan 2006 10:12:50 +0100

Chris Burdess wrote:
> Tom Tromey wrote:
> > Chris> Please comment.
> > 
> > Chris> -        dst[dstIndex + 1] = (char) ((codePoint & 0x3ff)
> > Chris> -                                    + (int) 
> MIN_LOW_SURROGATE );
> > Chris> -        dst[dstIndex] = (char) ((codePoint >> 10) + 
> (int) MIN_HIGH_SURROGATE);
> > Chris> +        dst[dstIndex + 1] = (char) (((codePoint - 
> 0x10000) % 0x400) + 0xdc00);
> > Chris> +        dst[dstIndex] = (char) (((codePoint - 
> 0x10000) / 0x400) + 0xd800);
> > 
> > I think it is better to use the named constants instead of 
> the values.
> 
> Fair enough, but what about the casting: doesn't that make it 
> less efficient?

No, it's a no-op (and not even needed in the source).

> > I also have a mild preference for the bit-shifting and masking
> > computation, but this is more minor.
> 
> The problem is that the bit-shifting method produces the wrong result.

In this case they both produce the same result. I think the problem was
that the original code forgot to subtract 0x10000.

Regards,
Jeroen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]