The function utf8_decode() was a shortcut to convert strings
encoded infrom UTF-8 to ISO-8859-1 ("Latin 1") to and from UTF-8.
This function was deprecated since PHP 8.2 and will probablybe dropped
will be removed in future versions:in PHP 9:
https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode
This change applies the exact proposed equivalentAs mentioned in the RFC, that is:if a $string is a valid UTF-8 string,
so this could be used to count the number of code points:
mb_convert_encodingstrlen(utf8_decode($string, 'ISO-8859-1'))
Note that this function exists since PHP 4, so, there are noThat works because any unmappable code point is replaced with the
compatibility issues.single byte '?' in the output. The native PHP approach is this one:
mb_strlen($string, 'UTF-8');
Also, another approach is this one:
iconv_strlen($string, 'UTF-8')
Note that the first method can be adopted since PHP 4, so, there
are no compatibility issues.
https://we.phorge.it/T15188
https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode
https://www.php.net/manual/en/function.utf8-decode
https://www.php.net/manual/en/function.mb-convert-encoding.php
https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#utf8decodeencodetombconvertencodingrector
Closes T15188