function newsfeedEncoding( $rssDoc ) {
// test if PHP 5
if ( phpversion() >= 5 ) {
// test if page is utf-8
if ( strpos(_ISO,'utf')!== false || strpos(_ISO,'UTF') !== false ) {
$encoding = 'html_entity_decode';
} else {
// non utf-8 page
$encoding = 'utf8tolatin2';
}
} else {
// handling for PHP 4
// determine encoding of feed
$text = $rssDoc->toNormalizedString(true);
$text = substr( $text, 0, 100 );
$utf8 = strpos( $text, 'encoding="utf-8"' );
// test if feed is utf-8
if ( $utf8 !== false ) {
// test if page is utf-8
if ( strpos(_ISO,'utf')!== false || strpos(_ISO,'UTF') !== false ) {
$encoding = 'html_entity_decode';
} else {
// non utf-8 page
$encoding = 'utf8tolatin2';
}
} else {
// handling for non utf-8 feed
// test if page is utf-8
if ( strpos(_ISO,'utf') !== false || strpos(_ISO,'UTF') !== false ) {
$encoding = 'utf8tolatin2';
} else {
// non utf-8 page
$encoding = 'html_entity_decode';
}
}
}
return $encoding;
}
}
function utf8tolatin2($content){
return iconv("UTF8","LATIN2",$content);
}