From 54c64ef0dc567a737be7703805ec8a040439c297 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 5 Feb 2006 22:41:31 +0000 Subject: [PATCH] Added UTF-8 support to the XML parser --- dev/changes.txt | 3 ++- xml.php | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dev/changes.txt b/dev/changes.txt index 5118148..a2c8ede 100644 --- a/dev/changes.txt +++ b/dev/changes.txt @@ -33,4 +33,5 @@ CHANGELOG FOR 2.0 - Added explain_error_reporting() so you can get an overview of all the constants and if they're enabled [kernel.php] - Added transaction capabilities to database layers - The mail module now supports multiple recipients and HTML multiparts [mail.php] -- ISSO::escape() no longer has a binary option [kernel.php] \ No newline at end of file +- ISSO::escape() no longer has a binary option [kernel.php] +- Added UTF-8 support to the XML parser [xml.php] \ No newline at end of file diff --git a/xml.php b/xml.php index d8e6594..5355d8f 100644 --- a/xml.php +++ b/xml.php @@ -151,10 +151,11 @@ class XML * @access public * * @param string XML file data + * @param string Parse file as UTF-8 instead of ISSO-8859-1 * * @return array Array with all the XML data parsed */ - function parse($data) + function parse($data, $utf8 = true) { $this->registry->check_isso_fields(get_class($this)); @@ -162,9 +163,18 @@ class XML $this->attribs = array(); $this->result = array(); $this->cdata = ''; - + + if ($utf8) + { + $data = utf8_encode($data); + $this->parser = xml_parser_create('UTF-8'); + } + else + { + $this->parser = xml_parser_create('ISSO-8859-1'); + } + // create a new parser - $this->parser = xml_parser_create(); xml_set_object($this->parser, $this); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); xml_set_element_handler($this->parser, 'handle_tag_start', 'handle_tag_end'); -- 2.43.5