summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictoria Lease <violets@google.com>2013-11-01 20:22:41 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-11-01 20:22:42 +0000
commitee4c84642afffa80f23039bbc2d4f59de11f67da (patch)
treec89affb2740cf04908d85a85f2a1ecd13ae56888
parent4846a93b55d7c8bf1af78cbeb3389801cff28e99 (diff)
parent3d4764159c78857bbd3305f4fa9c11c70e742d88 (diff)
downloadframeworks_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.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 == ' ') {