1--TEST--
2mb_internal_encoding()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7// TODO:
8//$debug = true;
9ini_set('include_path', dirname(__FILE__));
10include_once('common.inc');
11
12// EUC-JP
13$r = mb_internal_encoding('EUC-JP');
14($r === TRUE) ? print "OK_EUC-JP_SET\n" : print "NG_EUC-JP_SET\n";
15$enc = mb_internal_encoding();
16print "$enc\n";
17
18// UTF-8
19$r = mb_internal_encoding('UTF-8');
20($r === TRUE) ? print "OK_UTF-8_SET\n" : print "NG_UTF-8_SET\n";
21$enc = mb_internal_encoding();
22print "$enc\n";
23
24// ASCII
25$r = mb_internal_encoding('ASCII');
26($r === TRUE) ? print "OK_ASCII_SET\n" : print "NG_ASCII_SET\n";
27$enc = mb_internal_encoding();
28print "$enc\n";
29
30// Invalid Parameter
31print "== INVALID PARAMETER ==\n";
32
33// Note: Other than string type, PHP raises Warning
34$r = mb_internal_encoding('BAD');
35($r === false) ? print "OK_BAD_SET\n" : print "NG_BAD_SET\n";
36$enc = mb_internal_encoding();
37print "$enc\n";
38
39$r = mb_internal_encoding($t_ary);
40($r === NULL) ? print "OK_BAD_ARY_SET\n" : print "NG_BAD_ARY_SET\n";
41$enc = mb_internal_encoding();
42print "$enc\n";
43
44$r = mb_internal_encoding($t_obj);
45($r === NULL) ? print "OK_BAD_OBJ_SET\n" : print "NG_BAD_OBJ_SET\n";
46$enc = mb_internal_encoding();
47print "$enc\n";
48
49?>
50--EXPECT--
51OK_EUC-JP_SET
52EUC-JP
53OK_UTF-8_SET
54UTF-8
55OK_ASCII_SET
56ASCII
57== INVALID PARAMETER ==
58ERR: Warning
59OK_BAD_SET
60ASCII
61ERR: Warning
62OK_BAD_ARY_SET
63ASCII
64ERR: Warning
65OK_BAD_OBJ_SET
66ASCII
67