ezyang/htmlpurifier

PHP 8.2 deprecated function utf8_decode , utf8_encode

Closed this issue · 4 comments

PHP 8.2 deprecated utf8_decode , utf8_encode and remove in PHP 9.0
https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode

utf8_encode function is ISO-8859-1 -> UTF8
utf8_decode function is UTF8 -> ISO-8859

so alternative function is iconv <- it's worng

@SharkMachine Is it really necessary to include symfony/polyfill-php72 here?

The suggestion from kitrio is not right, the primary replacement for utf8_encode and utf8_decode is mb_convert_encoding and available since PHP 4.0.6.

See section Proposal

Documentation and deprecation messages will encourage users to check that their usage is correct, and recommend mb_convert_encoding as the primary replacement, with UConverter::transcode and iconv also listed as possibilities.

Examples https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode#alternatives_to_removed_functionality

@Daijobou mb_convert_encoding can be used, but then mbstring extension will be an additional requirement.

The goal of my PR was to get rid of utf8_encode and utf8_decode without breaking changes. Without symfony/polyfill-php72 it would have required a lot of work

@Daijobou It's also not that simple #324 (comment), I already tried it