summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2004-02-17 23:36:22 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2004-02-17 23:36:22 +0000
commite45b242468759d55ce95c60d2fc0100b576ef8d5 (patch)
tree265926df9be89108d9f29a33c0cc143215b7cbc4
parent7abb76e1d1d975102ed994c5404de44ea8811ab5 (diff)
downloadbrdo-e45b242468759d55ce95c60d2fc0100b576ef8d5.tar.gz
brdo-e45b242468759d55ce95c60d2fc0100b576ef8d5.tar.bz2
- Added a short snippet to drupal_xml_parser_create() which invokes iconv() to convert unsupported encodings.
-rw-r--r--includes/common.inc14
1 files changed, 12 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 8815458be..8b446811b 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');