summaryrefslogtreecommitdiff
path: root/includes/unicode.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-03-09 14:46:33 +0000
committerDries Buytaert <dries@buytaert.net>2006-03-09 14:46:33 +0000
commit9145ed128cc1537ffa5534ee602bf8da97a0847e (patch)
treebd3708937c4992e84d37a0c62d12854c97787940 /includes/unicode.inc
parentc126bbaa21544f93b4d86b44fae6c93ceaba12a2 (diff)
downloadbrdo-9145ed128cc1537ffa5534ee602bf8da97a0847e.tar.gz
brdo-9145ed128cc1537ffa5534ee602bf8da97a0847e.tar.bz2
- Patch #49497 by damz and morbus: fixed encoding of feeds with PHP5.
Diffstat (limited to 'includes/unicode.inc')
-rw-r--r--includes/unicode.inc13
1 files changed, 7 insertions, 6 deletions
diff --git a/includes/unicode.inc b/includes/unicode.inc
index cd8285514..a2d1944c5 100644
--- a/includes/unicode.inc
+++ b/includes/unicode.inc
@@ -90,12 +90,13 @@ function unicode_settings() {
*
* This is a wrapper around xml_parser_create() which extracts the encoding from
* the XML data first and sets the output encoding to UTF-8. This function should
- * be used instead of xml_parser_create(), because PHP's XML parser doesn't check
- * the input encoding itself.
+ * be used instead of xml_parser_create(), because PHP 4's XML parser doesn't
+ * check the input encoding itself. "Starting from PHP 5, the input encoding is
+ * automatically detected, so that the encoding parameter specifies only the
+ * output encoding."
*
- * This is also where unsupported encodings will be converted.
- * Callers should take this into account: $data might have been changed after
- * the call.
+ * This is also where unsupported encodings will be converted. Callers should
+ * take this into account: $data might have been changed after the call.
*
* @param &$data
* The XML data which will be parsed later.
@@ -123,8 +124,8 @@ function drupal_xml_parser_create(&$data) {
if (!in_array(strtolower($encoding), $php_supported)) {
$out = drupal_convert_to_utf8($data, $encoding);
if ($out !== false) {
- $data = $out;
$encoding = 'utf-8';
+ $data = ereg_replace('^(<\?xml[^>]+encoding)="([^"]+)"', '\\1="utf-8"', $out);
}
else {
watchdog('php', t("Could not convert XML encoding '%s' to UTF-8.", array('%s' => $encoding)), WATCHDOG_WARNING);