xref: /PHP-8.4/ext/mbstring/tests/gh15824.phpt (revision dc5f3b95)
1--TEST--
2GH-15824 (ValueError: mb_detect_encoding(): Argument #2 ($encodings) contains invalid encoding "UTF8")
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7echo "== alias name ==\n";
8var_dump(mb_detect_encoding('abc', 'UTF8, ASCII'));
9var_dump(mb_detect_encoding('こんにちは', 'UTF8, ASCII'));
10var_dump(mb_detect_encoding('こんにちは', 'ASCII, UTF8'));
11var_dump(mb_detect_encoding("\xC5", 'US-ASCII, LATIN4'));
12var_dump(mb_detect_encoding("\xC5", 'US-ASCII, cyrillic'));
13/* 0x9D is not located in CP1254 */
14var_dump(mb_detect_encoding("\x9D", 'US-ASCII, CP1254, cyrillic'));
15var_dump(mb_detect_encoding("\x9D", 'US-ASCII, CP1254, cyrillic', false));
16
17echo "== mime name ==\n";
18var_dump(mb_detect_encoding('abc', 'ANSI_X3.4-1968, ISO-8859-1'));
19var_dump(mb_detect_encoding('abc', 'CP50220, ANSI_X3.4-1968'));
20/* last comma is not mistake, intentionally */
21var_dump(mb_detect_encoding(bin2hex('1b24422422242424262428242a1b2842'), 'CP50220, ANSI_X3.4-1968,', false));
22var_dump(mb_detect_encoding('��', 'US-ASCII, UTF-8-Mobile#KDDI-B, UTF-8'));
23?>
24--EXPECT--
25== alias name ==
26string(5) "UTF-8"
27string(5) "UTF-8"
28string(5) "UTF-8"
29string(10) "ISO-8859-4"
30string(10) "ISO-8859-5"
31string(10) "ISO-8859-5"
32string(10) "ISO-8859-5"
33== mime name ==
34string(5) "ASCII"
35string(7) "CP50220"
36string(7) "CP50220"
37string(19) "UTF-8-Mobile#KDDI-B"
38