Slightly improved code in drupal_xml_parser_create.

4.5.x
Steven Wittens 2004-07-12 21:38:41 +00:00
parent 77c0b577da
commit a080ce5f0f
1 changed files with 9 additions and 12 deletions

View File

@ -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);