Skip to content

Commit 532eee2

Browse files
committed
my current point of research regarding encodings
git-svn-id: https://svn.php.net/repository/pear/packages/XML_Parser/trunk@266400 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 258af3e commit 532eee2

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tests/005.phpt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ require_once "XML/Parser.php";
2222
class TestEncodings1 extends XML_Parser {
2323
var $output = '';
2424

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);
2727
}
2828
function startHandler($xp, $elem, $attribs) {
2929
$this->output .= "<$elem>";
@@ -35,16 +35,20 @@ class TestEncodings1 extends XML_Parser {
3535
$this->output .= $data;
3636
}
3737
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+
}
4142
}
4243
}
4344

4445
$xml = "<?xml version='1.0' ?>";
4546
$input = array(
4647
"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+
4852
"US-ASCII" => "<a>abcaoa</a>"
4953
);
5054

@@ -55,12 +59,12 @@ foreach ($input as $srcenc => $string) {
5559
continue;
5660
}
5761
print "Testing $srcenc -> $tgtenc: ";
58-
$p =& new TestEncodings1($tgtenc, $srcenc);
62+
$p =& new TestEncodings1($tgtenc, 'event', $srcenc);
5963
$e = $p->test($input[$srcenc]);
6064
if (PEAR::isError($e)) {
6165
printf("OOPS: %s\n", $e->getMessage());
6266
} else {
63-
var_dump($e);
67+
var_dump($p->output);
6468
}
6569
}
6670
}

0 commit comments

Comments
 (0)