Skip to content

Commit 215ddb7

Browse files
authored
ext/iconv/tests/bug52211.phpt: use per-iconv charset names (php#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.
1 parent 0b96441 commit 215ddb7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

ext/iconv/tests/bug52211.phpt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ iconv
55
--FILE--
66
<?php
77

8+
// According to POSIX 2024, the to/from charset names are
9+
// implementation-defined. To keep this test true to its original
10+
// purpose, we retain the charsets used in bug 52211, but only when
11+
// the implementation is known to support them. Otherwise we default
12+
// both to ASCII, which should be supported everywhere (in particular
13+
// on musl) yet still considers the input invalid.
14+
$from_charset = "ASCII";
15+
$to_charset = "ASCII";
16+
17+
if (ICONV_IMPL == "libiconv" || ICONV_IMPL == "glibc") {
18+
$from_charset = "CP850";
19+
$to_charset = "ISO-8859-1";
20+
}
21+
822
$str = "PATHOLOGIES MÉDICO-CHIRUR. ADUL. PL";
9-
$str_iconv = iconv('CP850', 'ISO-8859-1', $str );
23+
$str_iconv = iconv($from_charset, $to_charset, $str );
1024
var_dump($str_iconv);
1125

1226
?>

0 commit comments

Comments
 (0)