diff options
author | Victoria Lease <violets@google.com> | 2013-10-29 15:34:51 -0700 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2013-10-29 15:34:51 -0700 |
commit | 3d4764159c78857bbd3305f4fa9c11c70e742d88 (patch) | |
tree | a19f4c44fc73cb5677f02fbb3c88332101315dc0 | |
parent | ac5d3827409dff757531347c5232bb34ea727274 (diff) | |
download | frameworks_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.java | 9 |
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(">"); } else if (c == '&') { out.append("&"); + } 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 == ' ') { |