Android Utililty Methods HTML Encode

List of utility methods to do HTML Encode

Description

The list of methods to do HTML Encode are organized into topic(s).

Method

StringhtmEncode(String input)
htm Encode
if (null == input || "".equals(input)) {
    return input;
StringBuffer stringbuffer = new StringBuffer();
int j = input.length();
for (int i = 0; i < j; i++) {
    char c = input.charAt(i);
    switch (c) {
...
Stringhtmlencode(String str)
htmlencode
if (str == null) {
    return null;
return replace("\"", "&quot;", replace("<", "&lt;", str));
StringreplaceHTMLTags(final String source)
replace HTML Tags
String modified = new String(source);
return modified.replace("&nbsp;", " ").replace("&lt;", "<")
        .replace("&gt;", ">").replace("&amp;", "&")
        .replace("&quot;", "\"").replace("\n", "");
StringencodeHtml(String to_encode)
Encodes unicode characters as HTML entities
return TextUtils.htmlEncode(to_encode);
SpannedfromHTML(String textToTransform)
from HTML
return Html.fromHtml(textToTransform);
StringhtmlEncode(String stringToEncode)
html Encode
if (stringToEncode == null) {
    return null;
StringBuilder encodedString = new StringBuilder();
for (int i = 0; i < stringToEncode.length(); ++i) {
    final char ch = stringToEncode.charAt(i);
    if (Character.isLetterOrDigit(ch) || (ch == '.') || (ch == '~')
            || (ch == '-') || (ch == '_')) {
...