* Patch: FYI: Character fix
@ 2006-01-09 20:17 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2006-01-09 20:17 UTC (permalink / raw)
To: Java Patch List
I'm checking this in on the trunk and the 4.1 branch.
This pulls in a small Character fix from Chris Burdess.
Tom
Index: ChangeLog
from Chris Burdess <dog@gnu.org>
* java/lang/Character.java (toChars,toCodePoint): Correct these
methods to use algorithms from Unicode specification.
Index: java/lang/Character.java
===================================================================
--- java/lang/Character.java (revision 109497)
+++ java/lang/Character.java (working copy)
@@ -2320,11 +2320,11 @@
{
// Write second char first to cause IndexOutOfBoundsException
// immediately.
- dst[dstIndex + 1] = (char) ((codePoint & 0x3ff)
- + (int) MIN_LOW_SURROGATE );
- dst[dstIndex] = (char) ((codePoint >> 10) + (int) MIN_HIGH_SURROGATE);
+ final int cp2 = codePoint - 0x10000;
+ dst[dstIndex + 1] = (char) ((cp2 % 0x400) + (int) MIN_LOW_SURROGATE);
+ dst[dstIndex] = (char) ((cp2 / 0x400) + (int) MIN_HIGH_SURROGATE);
result = 2;
- }
+ }
else
{
dst[dstIndex] = (char) codePoint;
@@ -2433,7 +2433,8 @@
*/
public static int toCodePoint(char high, char low)
{
- return ((high - MIN_HIGH_SURROGATE) << 10) + (low - MIN_LOW_SURROGATE);
+ return ((high - MIN_HIGH_SURROGATE) * 0x400) +
+ (low - MIN_LOW_SURROGATE) + 0x10000;
}
/**
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-01-09 20:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-09 20:17 Patch: FYI: Character fix Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).