1--TEST--
2DOMDocument::$encoding - read/write tests (dom_document_encoding_read/dom_document_encoding_write)
3--CREDITS--
4Hans Zaunere
5# TestFest 2009 NYPHP
6--SKIPIF--
7<?php require_once('skipif.inc'); ?>
8--FILE--
9<?php
10
11require_once('dom_test.inc');
12
13$dom = new DOMDocument;
14$dom->loadXML($xmlstr);
15
16if( !$dom )
17{
18    echo "Error while parsing the document\n";
19    exit;
20}
21
22echo "Empty Encoding Read: '{$dom->encoding}'\n";
23
24try {
25    $ret = $dom->encoding = 'NYPHP DOMinatrix';
26    echo "Adding invalid encoding: $ret\n";
27} catch (\ValueError $e) {
28    echo $e->getMessage() . \PHP_EOL;
29}
30
31$ret = $dom->encoding = 'ISO-8859-1';
32echo "Adding ISO-8859-1 encoding: $ret\n";
33echo "ISO-8859-1 Encoding Read: {$dom->encoding}\n";
34
35$ret = $dom->encoding = 'UTF-8';
36echo "Adding UTF-8 encoding: $ret\n";
37echo "UTF-8 Encoding Read: {$dom->encoding}\n";
38
39$ret = $dom->encoding = 'UTF-16';
40echo "Adding UTF-16 encoding: $ret\n";
41echo "UTF-16 Encoding Read: {$dom->encoding}\n";
42
43
44?>
45--EXPECT--
46Empty Encoding Read: ''
47Invalid document encoding
48Adding ISO-8859-1 encoding: ISO-8859-1
49ISO-8859-1 Encoding Read: ISO-8859-1
50Adding UTF-8 encoding: UTF-8
51UTF-8 Encoding Read: UTF-8
52Adding UTF-16 encoding: UTF-16
53UTF-16 Encoding Read: UTF-16
54