summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);