Skip to content

utf8_decode is deprecated as of PHP8.2 (and probably wrong too) #9

@divinity76

Description

@divinity76

first off, utf8_decode() is deprecated as of PHP8.2, and you should use

mb_convert_encoding($str, 'utf-8', 'ISO-8859-1')

instead,

second, utf8_decode converts data from ISO-8859-1 to UTF-8,
which means that if your XML document is not encoded with ISO-8859-1, the function

    /**
     * Replaces all html entities into its original symbols.
     * 
     * @param string $content
     * @return string
     */
    public function convertEntities($content)
    {
        $table = array_map('utf8_encode', array_flip(
            array_diff(
                get_html_translation_table(HTML_ENTITIES), 
                get_html_translation_table(HTML_SPECIALCHARS)
            )
        ));
        return preg_replace('/&#[\d\w]+;/', '', strtr($content, $table));
    }

doesn't even make sense, and is likely to corrupt UTF-8 XMLs..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions