1--TEST--
2mb_http_output()
3--EXTENSIONS--
4mbstring
5--FILE--
6<?php
7//TODO: Add more encoding. Wrong parameter type test.
8ini_set('include_path', __DIR__);
9include_once('common.inc');
10
11// Set HTTP output encoding to ASCII
12$r = mb_http_output('ASCII');
13($r === TRUE) ? print "OK_ASCII_SET\n" : print "NG_ASCII_SET\n";
14$enc = mb_http_output();
15print "$enc\n";
16
17// Set HTTP output encoding to SJIS
18$r = mb_http_output('SJIS');
19($r === TRUE) ? print "OK_SJIS_SET\n" : print "NG_SJIS_SET\n";
20$enc = mb_http_output();
21print "$enc\n";
22
23// Set HTTP output encoding to JIS
24$r = mb_http_output('JIS');
25($r === TRUE) ? print "OK_JIS_SET\n" : print "NG_JIS_SET\n";
26$enc = mb_http_output();
27print "$enc\n";
28
29// Set HTTP output encoding to UTF8
30$r = mb_http_output('UTF-8');
31($r === TRUE) ? print "OK_UTF-8_SET\n" : print "NG_UTF-8_SET\n";
32$enc = mb_http_output();
33print "$enc\n";
34
35// Set HTTP output encoding to EUC-JP
36$r = mb_http_output('EUC-JP');
37($r === TRUE) ? print "OK_EUC-JP_SET\n" : print "NG_EUC-JP_SET\n";
38$enc = mb_http_output();
39print "$enc\n";
40
41// Invalid parameters
42print "== INVALID PARAMETER ==\n";
43
44// Note: Bad string raise ValueError. Bad Type raise Notice (Type Conversion) and ValueError
45try {
46    $r = mb_http_output('BAD_NAME');
47    print 'NG_BAD_SET' . \PHP_EOL;
48} catch (\ValueError $e) {
49    echo $e->getMessage() . \PHP_EOL;
50}
51$enc = mb_http_output();
52print "$enc\n";
53
54?>
55--EXPECT--
56OK_ASCII_SET
57ASCII
58OK_SJIS_SET
59SJIS
60OK_JIS_SET
61JIS
62OK_UTF-8_SET
63UTF-8
64OK_EUC-JP_SET
65EUC-JP
66== INVALID PARAMETER ==
67mb_http_output(): Argument #1 ($encoding) must be a valid encoding, "BAD_NAME" given
68EUC-JP
69