[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] RFC: patch for Unicode scalar value to UTF-16 conversio
From: |
Chris Burdess |
Subject: |
Re: [cp-patches] RFC: patch for Unicode scalar value to UTF-16 conversion |
Date: |
Sun, 8 Jan 2006 08:54:12 +0000 |
User-agent: |
Mutt/1.5.10i |
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?
Actually I should only be doing the subtraction once here on that basis.
> 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.
What about the version attached here, is that better?
--
Chris Burdess
"They that can give up essential liberty to obtain a little safety
deserve neither liberty nor safety." - Benjamin Franklin
patch
Description: Text document
pgpXjinYxOyys.pgp
Description: PGP signature