Closed
Description
Symfony version(s) affected
5.4.30
Description
Method \Symfony\Component\String\AbstractString::toByteString
throws ValueError
exception when unsupported encoding for mb_convert_encoding
is passed instead of using fallback iconv
.
How to reproduce
u('žsžsý')->toByteString('windows-1250');
Throws ValueError
with message mb_convert_encoding(): Argument #2 ($to_encoding) must be a valid encoding, "windows-1250" given
.
Instead of returning ByteString
with output of iconv
Possible Solution
No response
Additional Context
iconv('UTF-8', 'windows-1250', 'žsžsý')
returns expected value.
Using PHP 8.1
It is possible that nobody noticed that PHP 8.0 added ValueError exception https://www.php.net/manual/en/function.mb-convert-encoding so the code is not compatible with php >= 8.0