1--TEST--
2mb_preferred_mime_name()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7// TODO: Add more encoding names
8
9$str = mb_preferred_mime_name('sjis-win');
10echo "$str\n";
11
12$str = mb_preferred_mime_name('SJIS');
13echo "$str\n";
14
15$str = mb_preferred_mime_name('EUC-JP');
16echo "$str\n";
17
18$str = mb_preferred_mime_name('UTF-8');
19echo "$str\n";
20
21$str = mb_preferred_mime_name('ISO-2022-JP');
22echo "$str\n";
23
24$str = mb_preferred_mime_name('JIS');
25echo "$str\n";
26
27$str = mb_preferred_mime_name('ISO-8859-1');
28echo "$str\n";
29
30$str = mb_preferred_mime_name('UCS2');
31echo "$str\n";
32
33$str = mb_preferred_mime_name('UCS4');
34echo "$str\n";
35
36echo "== INVALID PARAMETER ==\n";
37// Invalid encoding
38try {
39    var_dump(mb_preferred_mime_name('BAD_NAME'));
40} catch (\ValueError $e) {
41    echo $e->getMessage() . \PHP_EOL;
42}
43
44?>
45--EXPECT--
46Shift_JIS
47Shift_JIS
48EUC-JP
49UTF-8
50ISO-2022-JP
51ISO-2022-JP
52ISO-8859-1
53UCS-2
54UCS-4
55== INVALID PARAMETER ==
56mb_preferred_mime_name(): Argument #1 ($encoding) must be a valid encoding, "BAD_NAME" given
57