Java HTML Escape htmlEscapeBasicMarkup(final String text)

Here you can find the source of htmlEscapeBasicMarkup(final String text)

Description

Performs necessary escaping to render arbitrary plain text as plain text without any markup.

License

LGPL

Declaration

public static String htmlEscapeBasicMarkup(final String text) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**/*from  ww  w . jav  a 2s  . c  om*/
     * Performs necessary escaping to render arbitrary plain text as plain text
     * without any markup.
     */
    public static String htmlEscapeBasicMarkup(final String text) {
        final StringBuilder buf = new StringBuilder(text.length() + 64);
        for (int i = 0; i < text.length(); i++) {
            final char ch = text.charAt(i);
            switch (ch) {
            case '<':
                buf.append("&lt;");
                break;
            case '&':
                buf.append("&amp;");
                break;
            case '>':
                buf.append("&gt;");
                break;
            default:
                buf.append(ch);
                break;
            }
        }
        return buf.toString();
    }
}

Related

  1. htmlEscape(String str)
  2. htmlEscape(String string)
  3. htmlEscape(String tag)
  4. htmlEscape(String text)
  5. htmlescapeAll(String s1)
  6. HTMLEscapeBr(String original)
  7. htmlEscapeSpace(String uri)
  8. htmlUnescape(String safeHtml)