Dominikus Scherkl <Dominikus dot Scherkl at glueckkanja dot com> wrote:

> utf16high = 0xD7C0 + (utf32 >> 10);
> utf16low  = 0xDC00 + (utf32 & 1023);
>
> this is very easy to invert:
>
> utf32 = ((utf16high - 0xD7C0) <<10) + (utf16low & 1023);

This is good, but I'd write hexadecimal 0x3FF instead of decimal 1023,
as it shows the purpose of the bitmask a little more clearly.
(Apologies to Karl Pentzlin, if he is still on this list.)

-Doug Ewell
 Fullerton, California


Reply via email to