From b8a6ed644b75ca2b0df05bd4ae2e3d91d1a94170 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 13 Sep 2004 07:42:13 +0000 Subject: [PATCH] Checking in fixes to xml_parser_create to specify an encoding (UTF-8) See Eloy's bug 1927 for details. After this checkin I'll be immediately testing some backup/restores on PHP 4. --- backup/restorelib.php | 2 +- filter/multilang/filter.php | 2 +- lib/xmlize.php | 4 ++-- mod/scorm/lib.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backup/restorelib.php b/backup/restorelib.php index 8b2d5ca8ed4..18c928afde7 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2961,7 +2961,7 @@ $status = true; - $xml_parser = xml_parser_create(); + $xml_parser = xml_parser_create('UTF-8'); $moodle_parser = new MoodleParser(); $moodle_parser->todo = $todo; $moodle_parser->preferences = $preferences; diff --git a/filter/multilang/filter.php b/filter/multilang/filter.php index c736e460ac0..440caa63352 100644 --- a/filter/multilang/filter.php +++ b/filter/multilang/filter.php @@ -103,7 +103,7 @@ class XMLParser { $this->texts['en'] = $data; /// Create parser - $xml_parser = xml_parser_create(); + $xml_parser = xml_parser_create('UTF-8'); xml_set_object($xml_parser, &$this); xml_set_element_handler($xml_parser, 'startElement', 'endElement'); xml_set_character_data_handler($xml_parser, 'characterData'); diff --git a/lib/xmlize.php b/lib/xmlize.php index 3bffc6a0397..db9df078547 100644 --- a/lib/xmlize.php +++ b/lib/xmlize.php @@ -20,11 +20,11 @@ * */ -function xmlize($data, $WHITE=1) { +function xmlize($data, $WHITE=1, $encoding='UTF-8') { $data = trim($data); $vals = $index = $array = array(); - $parser = xml_parser_create(); + $parser = xml_parser_create($encoding); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, $WHITE); xml_parse_into_struct($parser, $data, $vals, $index); diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php index 97a40426d15..b3c90b72bb7 100755 --- a/mod/scorm/lib.php +++ b/mod/scorm/lib.php @@ -481,7 +481,7 @@ function scorm_parse($basedir,$file,$scorm_id) { $level = 0; $parent[$level] = '/'; - $xml_parser = xml_parser_create(); + $xml_parser = xml_parser_create('UTF-8'); // use case-folding so we are sure to find the tag in $map_array xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($xml_parser, 'scorm_startElement', 'scorm_endElement');