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