1--TEST--
2Test iconv_get_encoding()/iconv_set_encoding() function : basic functionality
3--SKIPIF--
4<?php
5extension_loaded('iconv') or die('skip');
6function_exists('iconv_get_encoding') or die("skip iconv_get_encoding() is not available in this build");
7?>
8--INI--
9iconv.input_encoding=ISO-8859-1
10iconv.internal_encoding=ISO-8859-1
11iconv.output_encoding=ISO-8859-1
12--FILE--
13<?php
14/* Prototype  : mixed iconv_get_encoding([string type])
15 * Description: Get internal encoding and output encoding for ob_iconv_handler()
16 * Prototype  : bool iconv_set_encoding(string type, string charset)
17 * Description: Sets internal encoding and output encoding for ob_iconv_handler()
18 * Source code: ext/iconv/iconv.c
19 */
20
21/*
22 * Test Basic functionality of iconv_get_encoding/iconv_set_encoding
23 */
24
25echo "*** Testing iconv_get_encoding()/iconv_set_encoding() : basic functionality ***\n";
26
27echo "--- Default get_encoding ---\n";
28var_dump(iconv_get_encoding());
29var_dump(iconv_get_encoding("input_encoding"));
30var_dump(iconv_get_encoding("output_encoding"));
31var_dump(iconv_get_encoding("internal_encoding"));
32var_dump(iconv_get_encoding("all"));
33
34echo "\n--- Altering encodings ---\n";
35var_dump(iconv_set_encoding("input_encoding", "UTF-8"));
36var_dump(iconv_set_encoding("output_encoding", "UTF-8"));
37var_dump(iconv_set_encoding("internal_encoding", "UTF-8"));
38
39
40echo "\n--- results of alterations ---\n";
41var_dump(iconv_get_encoding());
42var_dump(iconv_get_encoding("input_encoding"));
43var_dump(iconv_get_encoding("output_encoding"));
44var_dump(iconv_get_encoding("internal_encoding"));
45var_dump(iconv_get_encoding("all"));
46
47
48echo "Done";
49?>
50--EXPECTF--
51*** Testing iconv_get_encoding()/iconv_set_encoding() : basic functionality ***
52--- Default get_encoding ---
53array(3) {
54  ["input_encoding"]=>
55  string(10) "ISO-8859-1"
56  ["output_encoding"]=>
57  string(10) "ISO-8859-1"
58  ["internal_encoding"]=>
59  string(10) "ISO-8859-1"
60}
61string(10) "ISO-8859-1"
62string(10) "ISO-8859-1"
63string(10) "ISO-8859-1"
64array(3) {
65  ["input_encoding"]=>
66  string(10) "ISO-8859-1"
67  ["output_encoding"]=>
68  string(10) "ISO-8859-1"
69  ["internal_encoding"]=>
70  string(10) "ISO-8859-1"
71}
72
73--- Altering encodings ---
74bool(true)
75bool(true)
76bool(true)
77
78--- results of alterations ---
79array(3) {
80  ["input_encoding"]=>
81  string(5) "UTF-8"
82  ["output_encoding"]=>
83  string(5) "UTF-8"
84  ["internal_encoding"]=>
85  string(5) "UTF-8"
86}
87string(5) "UTF-8"
88string(5) "UTF-8"
89string(5) "UTF-8"
90array(3) {
91  ["input_encoding"]=>
92  string(5) "UTF-8"
93  ["output_encoding"]=>
94  string(5) "UTF-8"
95  ["internal_encoding"]=>
96  string(5) "UTF-8"
97}
98Done
99