diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-07-12 21:35:31 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-07-12 21:35:31 +0000 |
commit | 77c0b577dac74a7d9941fa6a4be7f1d2ebdc4a90 (patch) | |
tree | f9e0cd0c12cd137879cf3854453bde20ea22f6d6 | |
parent | 71eca365476fc20295bcecf3bf475ba1090f1580 (diff) | |
download | brdo-77c0b577dac74a7d9941fa6a4be7f1d2ebdc4a90.tar.gz brdo-77c0b577dac74a7d9941fa6a4be7f1d2ebdc4a90.tar.bz2 |
Now Drupal tries iconv, recode and mbstring to convert unknown XML encodings to UTF-8. It also throws a friendlier error message when none of these extensions is installed.
-rw-r--r-- | includes/common.inc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/includes/common.inc b/includes/common.inc index 972f62947..8ef824dac 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1273,17 +1273,35 @@ function drupal_xml_parser_create(&$data) { /* * Unsupported encodings are converted here into UTF-8. - * Requires iconv, see http://www.php.net/iconv + * Requires the iconv, GNU recode or mbstring PHP extension. */ $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); + $out = @iconv($encoding, 'utf-8', $data); if ($out !== false) { $data = $out; $encoding = 'utf-8'; } } + else if (function_exists('mb_convert_encoding')) { + $out = @mb_convert_encoding($data, 'utf-8', $encoding); + if ($out !== false) { + $data = $out; + $encoding = 'utf-8'; + } + } + else if (function_exists('recode_string')) { + $out = @recode_string($encoding . '..utf-8', $data); + if ($out !== false) { + $data = $out; + $encoding = 'utf-8'; + } + } + else { + watchdog(t("Unsupported XML encoding '%s'. Please install iconv, GNU recode or mbstring for PHP.", $encoding)); + return 0; + } } $xml_parser = xml_parser_create($encoding); |