From 3a9be438946017ead7a73eee15073379bfae5197 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Thu, 13 Mar 2014 11:11:27 +0400 Subject: [PATCH] Fixes some UTF-16 relates issues --- .../main/java/org/teavm/classlib/impl/charset/UTF16Helper.java | 1 + .../org/teavm/classlib/java/lang/TAbstractStringBuilder.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/impl/charset/UTF16Helper.java b/teavm-classlib/src/main/java/org/teavm/classlib/impl/charset/UTF16Helper.java index 29afb680e..44ad12c12 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/impl/charset/UTF16Helper.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/impl/charset/UTF16Helper.java @@ -30,6 +30,7 @@ public class UTF16Helper { public static final int SUPPLEMENTARY_PLANE = 0x10000; public static char highSurrogate(int codePoint) { + codePoint -= SUPPLEMENTARY_PLANE; return (char)(HIGH_SURROGATE_BITS | (codePoint >> MEANINGFUL_SURROGATE_BITS) & SURROGATE_BIT_INV_MASK); } diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java index 754c5f0b4..3040bbdfc 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java @@ -552,7 +552,6 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ return append((char)codePoint); } ensureCapacity(length + 2); - codePoint -= UTF16Helper.SUPPLEMENTARY_PLANE; buffer[length++] = UTF16Helper.highSurrogate(codePoint); buffer[length++] = UTF16Helper.lowSurrogate(codePoint); return this;