@Immutable
    public static Memory html_entity_decode(Environment env, TraceInfo trace,
                                            Memory _string, int flags, String encoding) {
        try {
            String string = new String(_string.getBinaryBytes(env.getDefaultCharset()), encoding);

            int len = string.length();
            int htmlEntityStart = -1;
            StringBuilder result = new StringBuilder();

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

                if (ch == '&' && htmlEntityStart < 0) {
                    htmlEntityStart = i;
                } else if (htmlEntityStart < 0) {
                    result.append(ch);
                } else if (ch == ';') {
                    String entity = string.substring(htmlEntityStart, i + 1);
                    Memory value = htmlEntriesMap().getByScalar(entity);

                    if (value == null) {
                        result.append(entity);
                    } else {
                        result.append(value);
                    }

                    htmlEntityStart = -1;
                } else if (!(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))) {
                    result.append('&');
                    i = htmlEntityStart;
                    htmlEntityStart = -1;
                }
            }

            if (htmlEntityStart > 0) {
                result.append(string, htmlEntityStart, len);
            }

            return new StringMemory(result.toString());
        } catch (UnsupportedEncodingException e) {
            env.warning(trace, "html_entity_decode(): 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