This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Character fix
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 09 Jan 2006 13:12:59 -0700
- Subject: Patch: FYI: Character fix
- Reply-to: tromey at redhat dot com
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;
}
/**