ezyang / htmlpurifier

Standards compliant HTML filter written in PHP
http://htmlpurifier.org
GNU Lesser General Public License v2.1
3.03k stars 323 forks source link

PHP 8.2 deprecated function utf8_decode , utf8_encode #320

Closed kitrio closed 1 year ago

kitrio commented 2 years ago

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

Daijobou commented 2 years ago

@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

SharkMachine commented 1 year ago

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

SharkMachine commented 1 year ago

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

SharkMachine commented 1 year ago

@Daijobou It's also not that simple https://github.com/ezyang/htmlpurifier/pull/324#issuecomment-1190515412, I already tried it