goja-core/src/main/java/goja/core/kits/lang/Strs.java
public static String escapeHtml(CharSequence cs) {
        if (null == cs)
            return null;
        char[] cas = cs.toString().toCharArray();
        StringBuilder sb = new StringBuilder();
        for (char c : cas) {
            switch (c) {
                case '&':
                    sb.append("&amp;");
                    break;
                case '<':
                    sb.append("&lt;");
                    break;
                case '>':
                    sb.append("&gt;");
                    break;
                case '\'':
                    sb.append("&#x27;");
                    break;
                case '"':
                    sb.append("&quot;");
                    break;
                default:
                    sb.append(c);
            }
        }
        return sb.toString();
    }
public static String escapeHtml(CharSequence cs) {
        if (null == cs)
            return null;
        char[] cas = cs.toString().toCharArray();
        StringBuilder sb = new StringBuilder();
        for (char c : cas) {
            switch (c) {
                case '&':
                    sb.append("&amp;");
                    break;
                case '<':
                    sb.append("&lt;");
                    break;
                case '>':
                    sb.append("&gt;");
                    break;
                case '\'':
                    sb.append("&#x27;");
                    break;
                case '"':
                    sb.append("&quot;");
                    break;
                default:
                    sb.append(c);
            }
        }
        return sb.toString();
    }
public static String escapeHtml ( CharSequence cs ) { if ( null == cs ) return null ; char [ ] cas = cs . toString ( ) . toCharArray ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( char c : cas ) { switch ( c ) { case ' ' : sb . append ( "&amp;" ) ; break ; case ' ' : sb . append ( "&lt;" ) ; break ; case ' ' : sb . append ( "&gt;" ) ; break ; case ' ' : sb . append ( "&#x27;" ) ; break ; case ' ' : sb . append ( "&quot;" ) ; break ; default : sb . append ( c ) ; } } return sb . toString ( ) ; }
将一个字符串出现的HMTL元素进行转义，比如
<p/>
<pre>
escapeHtml("&lt;script&gt;alert("hello world");&lt;/script&gt;") => "&amp;lt;script&amp;gt;alert(&amp;quot;hello world&amp;quot;);&amp;lt;/script&amp;gt;"
</pre>
<p/>
转义字符对应如下
<ul>
<li>& => &amp;amp;
<li>< => &amp;lt;
<li>>=> &amp;gt;
<li>' => &amp;#x27;
<li>" => &amp;quot;
</ul>

@param cs 字符串
@return 转换后字符串
将一个字符串出现的HMTL元素进行转义，比如 <p / > <pre > escapeHtml ( &lt ; script&gt ; alert ( hello world ) ; &lt ; / script&gt ; ) = > &amp ; lt ; script&amp ; gt ; alert ( &amp ; quot ; hello world&amp ; quot ; ) ; &amp ; lt ; / script&amp ; gt ; < / pre > <p / > 转义字符对应如下 <ul > <li > & = > &amp ; amp ; <li > < = > &amp ; lt ; <li >> = > &amp ; gt ; <li > = > &amp ; #x27 ; <li > = > &amp ; quot ; < / ul >