Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d476415 authored by Victoria Lease's avatar Victoria Lease
Browse files

Handle surrogate pairs in Html.toHtml()

Bug: 11338711
Change-Id: Ia44187cbfe3db82d6bc11c1ae3a0fb59c0a6d371
parent ac5d3827
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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 == ' ') {