function getEncoding()
{
$root = $this->getRoot();
if ($root !== null) {
if ($enc = $root->select('meta[charset]', 0, true, true)) {
return $enc->getAttribute("charset");
} elseif ($enc = $root->select('"?xml"[encoding]', 0, true, true)) {
return $enc->getAttribute("encoding");
} elseif ($enc = $root->select('meta[content*="charset="]', 0, true, true)) {
$enc = $enc->getAttribute("content");
return substr($enc, strpos($enc, "charset=") + 8);
}
}
return false;
}