[php-src] PHP-8.4: ext/iconv/tests/bug52211.phpt: use per-iconv charset names (#22543)
Michael Orlitzky via GitHub <[email protected]>
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: Michael Orlitzky (orlitzky)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-07-08T15:41:58+01:00
Commit: https://github.com/php/php-src/commit/215ddb732e1481a43a77d5815014a32e2c76751a
Raw diff: https://github.com/php/php-src/commit/215ddb732e1481a43a77d5815014a32e2c76751a.diff
ext/iconv/tests/bug52211.phpt: use per-iconv charset names (#22543)
The charset names used in this test are implementation-specific, and
in particular are not known to musl. This causes musl to fall back to
utf8, in which the input string is not actually invalid, leading to
a failed test. The input string is already invalid in ASCII however,
so we solve the general problem by using ASCII as the to/from charset
unless the ICONV_IMPL is known to support the originals.
Changed paths:
M ext/iconv/tests/bug52211.phpt
Diff:
diff --git a/ext/iconv/tests/bug52211.phpt b/ext/iconv/tests/bug52211.phpt
index f213c764de81..fe599f8ac559 100644
--- a/ext/iconv/tests/bug52211.phpt
+++ b/ext/iconv/tests/bug52211.phpt
@@ -5,8 +5,22 @@ iconv
--FILE--
<?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('CP850', 'ISO-8859-1', $str );
+$str_iconv = iconv($from_charset, $to_charset, $str );
var_dump($str_iconv);
?>