Android HTML String Escape checkHtmlView(String strString)

Here you can find the source of checkHtmlView(String strString)

Description

check Html View

Declaration

public static String checkHtmlView(String strString) 

Method Source Code

//package com.java2s;

public class Main {

    public static String checkHtmlView(String strString) {
        String strNew = "";

        try {/*from   w  w w  . j  a  v a 2  s. c  o  m*/
            StringBuffer strTxt = new StringBuffer("");

            char chrBuff;
            int len = strString.length();

            for (int i = 0; i < len; i++) {
                chrBuff = (char) strString.charAt(i);

                switch (chrBuff) {
                case '<':
                    strTxt.append("&lt;");
                    break;
                case '>':
                    strTxt.append("&gt;");
                    break;
                case '"':
                    strTxt.append("&quot;");
                    break;
                case 10:
                    strTxt.append("<br>");
                    break;
                case ' ':
                    strTxt.append("&nbsp;");
                    break;
                // case '&' :
                // strTxt.append("&amp;");
                // break;
                default:
                    strTxt.append(chrBuff);
                }
            }

            strNew = strTxt.toString();

        } catch (Exception ex) {
            return null;
        }

        return strNew;
    }
}

Related

  1. escapeHtml(String html)
  2. stripHTMLTags(String textToStrip)
  3. toHTMLString(String s)
  4. isHTML(String s)