From e45b242468759d55ce95c60d2fc0100b576ef8d5 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Tue, 17 Feb 2004 23:36:22 +0000 Subject: [PATCH] - Added a short snippet to drupal_xml_parser_create() which invokes iconv() to convert unsupported encodings. --- includes/common.inc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index 8815458be70..8b446811b03 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1203,9 +1203,19 @@ function drupal_xml_parser_create(&$data) { } /* - * Note: unsupported encodings will need to be converted here into UTF-8, - * and $encoding set to 'utf-8'. + * Unsupported encodings are converted here into UTF-8. + * Requires iconv, see http://www.php.net/iconv */ + $php_supported = array('utf-8', 'iso-8859-1', 'us-ascii'); + if (!in_array(strtolower($encoding), $php_supported)) { + if (function_exists('iconv')) { + $out = iconv($encoding, 'utf-8', $data); + if ($out !== false) { + $data = $out; + $encoding = 'utf-8'; + } + } + } $xml_parser = xml_parser_create($encoding); xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'utf-8');