public static Memory htmlentities(Environment env, TraceInfo trace,
                                      Memory _string, int quoteStyle, String encoding) {
        try {
            String string = new String(_string.getBinaryBytes(env.getDefaultCharset()), encoding);
            StringBuffer sb = new StringBuffer();

            int length = string.length();
            for (int i = 0; i < length; ++i) {
                char ch = string.charAt(i);
                Memory el = htmlEntriesMap().getByScalar(String.valueOf(ch));

                if (ch == '"') {
                    if ((quoteStyle & StringConstants.ENT_HTML_QUOTE_DOUBLE) != 0) {
                        sb.append("&quot;");
                    } else {
                        sb.append(ch);
                    }
                } else if (ch == '\'') {
                    if ((quoteStyle & StringConstants.ENT_HTML_QUOTE_SINGLE) != 0) {
                        sb.append("&#039;");
                    } else {
                        sb.append('\'');
                    }
                } else if (el != null) {
                    sb.append(el);
                } else {
                    sb.append(ch);
                }
            }
            return new StringMemory(sb.toString());
        } catch (UnsupportedEncodingException e) {
            env.warning(trace, "htmlentities(): unsupported encoding - %s", encoding);
            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