MCPcopy Create free account
hub / github.com/M66B/FairEmail / withinStyle

Method withinStyle

app/src/main/java/eu/faircode/email/HtmlEx.java:550–591  ·  view source on GitHub ↗
(StringBuilder out, CharSequence text,
                                          int start, int end)

Source from the content-addressed store, hash-verified

548
549 //@UnsupportedAppUsage
550 private /* static */ void withinStyle(StringBuilder out, CharSequence text,
551 int start, int end) {
552 for (int i = start; i < end; i++) {
553 try {
554 char c = text.charAt(i);
555
556 if (c == '<') {
557 out.append("&lt;");
558 } else if (c == '>') {
559 out.append("&gt;");
560 } else if (c == '&') {
561 out.append("&amp;");
562 } else if (c >= 0xD800 && c <= 0xDFFF) {
563 if (c < 0xDC00 && i + 1 < end) {
564 char d = text.charAt(i + 1);
565 if (d >= 0xDC00 && d <= 0xDFFF) {
566 i++;
567 int codepoint = 0x010000 | (int) c - 0xD800 << 10 | (int) d - 0xDC00;
568 out.append("&#").append(codepoint).append(";");
569 }
570 }
571 } else if (c > 0x7E || c < ' ') {
572 out.append("&#").append((int) c).append(";");
573 } else if (c == ' ') {
574 boolean img = (i - 1 >= 0 && text.charAt(i - i) == '\uFFFC');
575
576 while (i + 1 < end && text.charAt(i + 1) == ' ') {
577 out.append("&nbsp;");
578 i++;
579 }
580
581 out.append(img ? "&nbsp;" : ' ');
582 } else {
583 out.append(c);
584 }
585 } catch (Throwable ex) {
586 Log.e("withinStyle " + start + "..." + end + "/" + text.length() + " i=" + i +
587 "\n" + android.util.Log.getStackTraceString(ex));
588 throw ex;
589 }
590 }
591 }
592
593 private static int nextSpanTransition(Spanned text, int start, int limit, Class type) {
594 try {

Callers 2

escapeHtmlMethod · 0.95
withinParagraphMethod · 0.95

Calls 4

eMethod · 0.95
charAtMethod · 0.80
appendMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected