From 9145ed128cc1537ffa5534ee602bf8da97a0847e Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 9 Mar 2006 14:46:33 +0000 Subject: - Patch #49497 by damz and morbus: fixed encoding of feeds with PHP5. --- includes/unicode.inc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'includes/unicode.inc') 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); -- cgit v1.2.3