1--TEST--
2mb_detect_order()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--INI--
6mbstring.language=Japanese
7--FILE--
8<?php
9//$debug = true;
10ini_set('include_path', dirname(__FILE__));
11include_once('common.inc');
12
13
14// Set order to "auto"
15$r = mb_detect_order('auto');
16($r === TRUE) ? print "OK_AUTO\n" : print "NG_AUTO\n";
17print implode(', ', mb_detect_order()) . "\n";
18
19
20// Set order by string
21$r = mb_detect_order('SJIS,EUC-JP,JIS,UTF-8');
22($r === TRUE) ? print "OK_STR\n" : print "NG_STR\n";
23print implode(', ', mb_detect_order()) . "\n";
24
25
26// Set order by array
27$a[] = 'ASCII';
28$a[] = 'JIS';
29$a[] = 'EUC-JP';
30$a[] = 'UTF-8';
31$r = mb_detect_order($a);
32($r === TRUE) ? print "OK_ARRAY\n" : print "NG_ARRAY\n";
33print implode(', ', mb_detect_order()) . "\n";
34
35// Set invalid encoding. Should fail.
36print "== INVALID PARAMETER ==\n";
37
38$r = mb_detect_order('BAD_NAME');
39($r === FALSE) ? print "OK_BAD_STR\n" : print "NG_BAD_STR\n";
40print implode(', ', mb_detect_order()) . "\n";
41
42$a[] = 'BAD_NAME';
43$r = mb_detect_order($a);
44($r ===	FALSE) ? print "OK_BAD_ARRAY\n" : print "NG_BAD_ARRAY\n";
45print implode(', ', mb_detect_order()) . "\n";
46
47?>
48
49--EXPECT--
50OK_AUTO
51ASCII, JIS, UTF-8, EUC-JP, SJIS
52OK_STR
53SJIS, EUC-JP, JIS, UTF-8
54OK_ARRAY
55ASCII, JIS, EUC-JP, UTF-8
56== INVALID PARAMETER ==
57OK_BAD_STR
58ASCII, JIS, EUC-JP, UTF-8
59OK_BAD_ARRAY
60ASCII, JIS, EUC-JP, UTF-8
61
62