[php-src] Issue #23874: Bug #52211 (iconv() returns part of string on error) [ext/iconv/tests/bug52211.phpt
| From: | ArchMaster2024 | Date: | Thu, 24 Sep 2026 01:40:38 +0000 |
| Subject: | [php-src] Issue #23874: Bug #52211 (iconv() returns part of string on error) [ext/iconv/tests/bug52211.phpt | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252810@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/23874
Author: ArchMaster2024
### Description
The following code:
```php
// According to POSIX 2024, the to/from charset names are
// implementation-defined. To keep this test true to its original
// purpose, we retain the charsets used in bug 52211, but only when
// the implementation is known to support them. Otherwise we default
// both to ASCII, which should be supported everywhere (in particular
// on musl) yet still considers the input invalid.
$from_charset = "ASCII";
$to_charset = "ASCII";
if (ICONV_IMPL == "libiconv" || ICONV_IMPL == "glibc") {
$from_charset = "CP850";
$to_charset = "ISO-8859-1";
}
$str = "PATHOLOGIES MÉDICO-CHIRUR. ADUL. PL";
$str_iconv = iconv($from_charset, $to_charset, $str );
var_dump($str_iconv);
<?php
```
Resulted in this output:
```
Warning: iconv(): Wrong encoding, conversion from "CP850" to "ISO-8859-1" is not
allowed in /opt/php/8.6/php-8.6.0beta3/ext/iconv/tests/bug52211.php on line 18
bool(false)
```
But I expected this output instead:
```
Notice: iconv(): Detected an illegal character in input string in %s on line %d
bool(false)
```
### PHP Version
```plain
PHP 8.6.0beta3 (cli) (built: Sep 24 2026 01:10:42) (NTS DEBUG)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0-dev, Copyright © Zend by Perforce
with Zend OPcache v8.6.0beta3, Copyright ©, by Zend by Perforce
```
### Operating System
Fedora Linux 44 (Container Image)