@@ -22,8 +22,8 @@ require_once "XML/Parser.php";
22
22
class TestEncodings1 extends XML_Parser {
23
23
var $ output = '' ;
24
24
25
- function TestEncodings1 ($ to , $ from ) {
26
- $ this ->XML_Parser ($ from , ' event ' , $ to );
25
+ function TestEncodings1 ($ to , $ mode , $ from ) {
26
+ $ this ->XML_Parser ($ from , $ mode , $ to );
27
27
}
28
28
function startHandler ($ xp , $ elem , $ attribs ) {
29
29
$ this ->output .= "< $ elem> " ;
@@ -35,16 +35,20 @@ class TestEncodings1 extends XML_Parser {
35
35
$ this ->output .= $ data ;
36
36
}
37
37
function test ($ data ) {
38
- // $this->output = '';
39
- $ this ->parseString ($ data , true );
40
- return $ this ->output ;
38
+ $ result = $ this ->parseString ($ data , true );
39
+ if (PEAR ::isError ($ result )) {
40
+ return $ result ;
41
+ }
41
42
}
42
43
}
43
44
44
45
$ xml = "<?xml version='1.0' ?> " ;
45
46
$ input = array (
46
47
"UTF-8 " => "<a>abcæøå</a> " ,
47
- "ISO-8859-1 " => "<a>abcæøå</a> " ,
48
+
49
+ /* are these special chars allowed in ISO-8859-1 context??? */
50
+ "ISO-8859-1 " => "<a>abcæøå</a> " , // "ISO-8859-1" => "<a>abc¥<a>",
51
+
48
52
"US-ASCII " => "<a>abcaoa</a> "
49
53
);
50
54
@@ -55,12 +59,12 @@ foreach ($input as $srcenc => $string) {
55
59
continue ;
56
60
}
57
61
print "Testing $ srcenc -> $ tgtenc: " ;
58
- $ p =& new TestEncodings1 ($ tgtenc , $ srcenc );
62
+ $ p =& new TestEncodings1 ($ tgtenc , ' event ' , $ srcenc );
59
63
$ e = $ p ->test ($ input [$ srcenc ]);
60
64
if (PEAR ::isError ($ e )) {
61
65
printf ("OOPS: %s \n" , $ e ->getMessage ());
62
66
} else {
63
- var_dump ($ e );
67
+ var_dump ($ p -> output );
64
68
}
65
69
}
66
70
}
0 commit comments