Skip to content

Commit

Permalink
my current point of research regarding encodings
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/XML_Parser/trunk@266400 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
ashnazg committed Sep 16, 2008
1 parent fed24a3 commit dcbef55
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ require_once "XML/Parser.php";
class TestEncodings1 extends XML_Parser {
var $output = '';

function TestEncodings1($to, $from) {
$this->XML_Parser($from, 'event', $to);
function TestEncodings1($to, $mode, $from) {
$this->XML_Parser($from, $mode, $to);
}
function startHandler($xp, $elem, $attribs) {
$this->output .= "<$elem>";
Expand All @@ -35,16 +35,20 @@ class TestEncodings1 extends XML_Parser {
$this->output .= $data;
}
function test($data) {
// $this->output = '';
$this->parseString($data, true);
return $this->output;
$result = $this->parseString($data, true);
if (PEAR::isError($result)) {
return $result;
}
}
}

$xml = "<?xml version='1.0' ?>";
$input = array(
"UTF-8" => "<a>abcæøå</a>",
"ISO-8859-1" => "<a>abcæøå</a>",

/* are these special chars allowed in ISO-8859-1 context??? */
"ISO-8859-1" => "<a>abcæøå</a>", // "ISO-8859-1" => "<a>abc¥<a>",

"US-ASCII" => "<a>abcaoa</a>"
);

Expand All @@ -55,12 +59,12 @@ foreach ($input as $srcenc => $string) {
continue;
}
print "Testing $srcenc -> $tgtenc: ";
$p =& new TestEncodings1($tgtenc, $srcenc);
$p =& new TestEncodings1($tgtenc, 'event', $srcenc);
$e = $p->test($input[$srcenc]);
if (PEAR::isError($e)) {
printf("OOPS: %s\n", $e->getMessage());
} else {
var_dump($e);
var_dump($p->output);
}
}
}
Expand Down

0 comments on commit dcbef55

Please sign in to comment.