summaryrefslogtreecommitdiff
path: root/java/lang/Character.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/lang/Character.java')
-rw-r--r--java/lang/Character.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/java/lang/Character.java b/java/lang/Character.java
index e33c15585..b0535e8b6 100644
--- a/java/lang/Character.java
+++ b/java/lang/Character.java
@@ -3054,11 +3054,11 @@ public final class Character implements Serializable, Comparable<Character>
{
// 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;
@@ -3167,7 +3167,8 @@ public final class Character implements Serializable, Comparable<Character>
*/
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;
}
/**