Skip to content

Commit ee3caef

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Add unit tests for mb_detect_encoding on Polish text
2 parents 902d643 + 1a2c608 commit ee3caef

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ext/mbstring/tests/mb_detect_encoding.phpt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,24 @@ $sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
1212
$jis = base64_decode('GyRCRnxLXDhsJUYlLSU5JUgkRyQ5ISMbKEIwMTIzNBskQiM1IzYjNyM4IzkhIxsoQg==');
1313
// EUC-JP string
1414
$euc_jp = "\xC6\xFC\xCB\xDC\xB8\xEC\xA5\xC6\xA5\xAD\xA5\xB9\xA5\xC8\xA4\xC7\xA4\xB9\xA1\xA301234\xA3\xB5\xA3\xB6\xA3\xB7\xA3\xB8\xA3\xB9\xA1\xA3";
15+
// UTF-8
16+
$polish1 = "Zażółć gęślą jaźń.";
17+
$polish2 = "Wół poszedł spać bardzo wcześnie. A to zdanie bez ogonka.";
1518

1619
echo "== BASIC TEST ==\n";
1720

1821
print("SJIS: " . mb_detect_encoding($sjis, 'SJIS') . "\n");
19-
2022
print("JIS: " . mb_detect_encoding($jis, 'JIS') . "\n");
21-
2223
print("EUC-JP: " . mb_detect_encoding($euc_jp, 'UTF-8,EUC-JP,JIS') . "\n");
23-
2424
print("EUC-JP: " . mb_detect_encoding($euc_jp, 'JIS,EUC-JP') . "\n");
25+
print("UTF-8: " . mb_detect_encoding($polish1, 'UTF-8,UTF-16,ISO-8859-1') . "\n");
26+
print("UTF-8: " . mb_detect_encoding($polish2, 'UTF-8,UTF-16,ISO-8859-1') . "\n");
2527

2628
echo "== ARRAY ENCODING LIST ==\n";
2729

2830
$a = ['UTF-8', 'EUC-JP', 'SJIS', 'JIS'];
29-
3031
print("JIS: " . mb_detect_encoding($jis, $a) . "\n");
31-
3232
print("EUC-JP: " . mb_detect_encoding($euc_jp, $a) . "\n");
33-
3433
print("SJIS: " . mb_detect_encoding($sjis, $a) . "\n");
3534

3635
$test = "CHARSET=windows-1252:Do\xeb;John";
@@ -226,6 +225,8 @@ $deEncodings = [
226225
];
227226
test($deStrings, $deEncodings);
228227

228+
test([$polish1, $polish2], ['UTF-32BE', 'UTF-32LE', 'UTF-16BE', 'UTF-16LE', 'UTF-8', 'ISO-8859-2']);
229+
229230
echo "Done!\n";
230231

231232
?>
@@ -235,6 +236,8 @@ SJIS: SJIS
235236
JIS: JIS
236237
EUC-JP: EUC-JP
237238
EUC-JP: EUC-JP
239+
UTF-8: UTF-8
240+
UTF-8: UTF-8
238241
== ARRAY ENCODING LIST ==
239242
JIS: JIS
240243
EUC-JP: EUC-JP

0 commit comments

Comments
 (0)