Skip to content
Snippets Groups Projects
Commit a080ce5f authored by Steven Wittens's avatar Steven Wittens
Browse files

Slightly improved code in drupal_xml_parser_create.

parent 77c0b577
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -1279,29 +1279,26 @@ function drupal_xml_parser_create(&$data) {
if (!in_array(strtolower($encoding), $php_supported)) {
if (function_exists('iconv')) {
$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;
}
if ($out !== false) {
$data = $out;
$encoding = 'utf-8';
}
else {
watchdog(t("Could not convert XML encoding '%s' to UTF-8.", $encoding));
return 0;
}
}
$xml_parser = xml_parser_create($encoding);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment