public static Memory htmlspecialchars(Environment env, TraceInfo trace,
                                          Memory _string, int quoteStyle, String charset) {
        try {
            String string = new String(_string.getBinaryBytes(env.getDefaultCharset()), charset);
            int len = string.length();

            StringBuilderMemory sb = new StringBuilderMemory();

            for (int i = 0; i < len; i++) {
                char ch = string.charAt(i);

                switch (ch) {
                    case '&':
                        sb.append("&amp;");
                        break;
                    case '"':
                        if ((quoteStyle & StringConstants.ENT_HTML_QUOTE_DOUBLE) != 0) {
                            sb.append("&quot;");
                        } else {
                            sb.append(ch);
                        }
                        break;
                    case '\'':
                        if ((quoteStyle & StringConstants.ENT_HTML_QUOTE_SINGLE) != 0) {
                            sb.append("&#039;");
                        } else {
                            sb.append(ch);
                        }
                        break;
                    case '<':
                        sb.append("&lt;");
                        break;
                    case '>':
                        sb.append("&gt;");
                        break;
                    default:
                        sb.append(ch);
                        break;
                }
            }

            return sb;
        } catch (UnsupportedEncodingException e) {
            env.warning(trace, "htmlspecialchars(): unsupported encoding - %s", charset);
            return Memory.FALSE;
        }
    }
Parses the cslashes bitmap returning an actual bitmap.

@param charset the bitmap string

@return the actual bitmap
exts/jphp-zend-ext/src/main/java/org/develnext/jphp/zend/ext/standard/StringFunctions.java