diff options
author | Victoria Lease <violets@google.com> | 2013-11-01 20:22:41 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-11-01 20:22:42 +0000 |
commit | ee4c84642afffa80f23039bbc2d4f59de11f67da (patch) | |
tree | c89affb2740cf04908d85a85f2a1ecd13ae56888 | |
parent | 4846a93b55d7c8bf1af78cbeb3389801cff28e99 (diff) | |
parent | 3d4764159c78857bbd3305f4fa9c11c70e742d88 (diff) | |
download | frameworks_base-ee4c84642afffa80f23039bbc2d4f59de11f67da.zip frameworks_base-ee4c84642afffa80f23039bbc2d4f59de11f67da.tar.gz frameworks_base-ee4c84642afffa80f23039bbc2d4f59de11f67da.tar.bz2 |
Merge "Handle surrogate pairs in Html.toHtml()" into klp-dev
-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 == ' ') { |