Commit 9145ed12 authored by Dries's avatar Dries

- Patch #49497 by damz and morbus: fixed encoding of feeds with PHP5.

parent c126bbaa
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment