Java String Quote quoteForHTML(String toQuote)

Here you can find the source of quoteForHTML(String toQuote)

Description

Quotes each and every character, e.g.

License

Open Source License

Declaration

public static String quoteForHTML(String toQuote) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  w w  w.  ja  v  a 2  s . co m
     * Quotes each and every character, e.g. '!' as !. Used for verbatim
     * display of arbitrary strings that may contain HTML entities.
     */
    public static String quoteForHTML(String toQuote) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < toQuote.length(); ++i) {
            result.append("&#").append((int) toQuote.charAt(i)).append(';');
        }
        return result.toString();
    }
}

Related

  1. quoteExecutable(String executable)
  2. quoteFileName(String filename)
  3. quoteForBatchScript(String arg)
  4. quoteForCommandString(String s)
  5. quoteForCsv(final String field)
  6. quoteForMdx(StringBuilder buf, String val)
  7. quoteForRegEx(String input)
  8. quoteForXML(String from)
  9. quoteHost(final String hostname)