1--TEST--
2mb_internal_encoding()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7// TODO:
8ini_set('include_path', __DIR__);
9include_once('common.inc');
10
11// EUC-JP
12$r = mb_internal_encoding('EUC-JP');
13($r === TRUE) ? print "OK_EUC-JP_SET\n" : print "NG_EUC-JP_SET\n";
14$enc = mb_internal_encoding();
15print "$enc\n";
16
17// UTF-8
18$r = mb_internal_encoding('UTF-8');
19($r === TRUE) ? print "OK_UTF-8_SET\n" : print "NG_UTF-8_SET\n";
20$enc = mb_internal_encoding();
21print "$enc\n";
22
23// ASCII
24$r = mb_internal_encoding('ASCII');
25($r === TRUE) ? print "OK_ASCII_SET\n" : print "NG_ASCII_SET\n";
26$enc = mb_internal_encoding();
27print "$enc\n";
28
29// Invalid Parameter
30print "== INVALID PARAMETER ==\n";
31
32// Note: Other than string type, PHP raises Warning
33try {
34    $r = mb_internal_encoding('BAD_NAME');
35    print 'NG_BAD_SET' . \PHP_EOL;
36} catch (\ValueError $e) {
37    echo $e->getMessage() . \PHP_EOL;
38}
39
40$enc = mb_internal_encoding();
41print "$enc\n";
42
43?>
44--EXPECT--
45OK_EUC-JP_SET
46EUC-JP
47OK_UTF-8_SET
48UTF-8
49OK_ASCII_SET
50ASCII
51== INVALID PARAMETER ==
52mb_internal_encoding(): Argument #1 ($encoding) must be a valid encoding, "BAD_NAME" given
53ASCII
54