summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2013-10-29 15:34:51 -0700
committerVictoria Lease <violets@google.com>2013-10-29 15:34:51 -0700
commit3d4764159c78857bbd3305f4fa9c11c70e742d88 (patch)
treea19f4c44fc73cb5677f02fbb3c88332101315dc0
parentac5d3827409dff757531347c5232bb34ea727274 (diff)
downloadframeworks_base-3d4764159c78857bbd3305f4fa9c11c70e742d88.zip
frameworks_base-3d4764159c78857bbd3305f4fa9c11c70e742d88.tar.gz
frameworks_base-3d4764159c78857bbd3305f4fa9c11c70e742d88.tar.bz2
Handle surrogate pairs in Html.toHtml()
Bug: 11338711 Change-Id: Ia44187cbfe3db82d6bc11c1ae3a0fb59c0a6d371
-rw-r--r--core/java/android/text/Html.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/text/Html.java b/core/java/android/text/Html.java
index 160c630..f839d52 100644
--- a/core/java/android/text/Html.java
+++ b/core/java/android/text/Html.java
@@ -391,6 +391,15 @@ public class Html {
out.append("&gt;");
} else if (c == '&') {
out.append("&amp;");
+ } else if (c >= 0xD800 && c <= 0xDFFF) {
+ if (c < 0xDC00 && i + 1 < end) {
+ char d = text.charAt(i + 1);
+ if (d >= 0xDC00 && d <= 0xDFFF) {
+ i++;
+ int codepoint = 0x010000 | (int) c - 0xD800 << 10 | (int) d - 0xDC00;
+ out.append("&#").append(codepoint).append(";");
+ }
+ }
} else if (c > 0x7E || c < ' ') {
out.append("&#").append((int) c).append(";");
} else if (c == ' ') {