Add some more methods needed by NewPipe. Mostly stubs

This commit is contained in:
Julian Winkler
2024-02-17 15:15:05 +01:00
parent 72d6ad9914
commit 5dfadc9c59
17 changed files with 91 additions and 13 deletions

View File

@@ -4,4 +4,19 @@ public class Html {
public static Spanned fromHtml(String source) {
return new SpannableString(source.replace("<br/>", "\n")); // TODO when JTidy is in use: s/<br \/>//g
}
public static String escapeHtml(CharSequence source) {
StringBuilder out = new StringBuilder(source.length());
for (int i = 0; i < source.length(); i++) {
char c = source.charAt(i);
if (c == '<' || c == '>' || c == '&' || c == '"' || c == '\'' || c > 0x7F) {
out.append("&#");
out.append((int) c);
out.append(';');
} else {
out.append(c);
}
}
return out.toString();
}
}