Problem/Motivation

When switching to PHP 8.2 got warning Call to deprecated function utf8_encode in modules/contrib/feeds/plugins/FeedsProcessor.inc, line 1484

Proposed resolution

I could suggest to use mb_convert_encoding

Comments

Dmitrii_Zadorozhnyi created an issue. See original summary.

Dmitrii_Zadorozhnyi’s picture

StatusFileSize
new601 bytes
megachriz’s picture

Status: Active » Needs work

Thanks for the patch, but I think there's a small error in it:

I think that the parameters 'ISO-8859-1' and 'UTF-8' need to be swapped:

  • utf8_encode() converts ISO-8859-1 to UTF-8
  • mb_convert_encoding() signature is $string, $to_encoding, $from_encoding. So the desired encoding of the result, in this case 'UTF-8' is the second parameter. The third parameter is the current encoding used to interpret string, in this case ' ISO-8859-1'.

By the way: I see that the tests report much more PHP 8.2 deprecations, but these could be handled in an other issue.

Dmitrii_Zadorozhnyi’s picture

StatusFileSize
new601 bytes

Fixed

megachriz’s picture

Status: Needs work » Fixed

Thanks! Committed #4.

Dmitrii_Zadorozhnyi’s picture

Title: PHP 8.2 Deprecated function: utf8_decode() » PHP 8.2 Deprecated function: utf8_encode()

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.