PHP Universal Feed Generatorでタイトルの文字化け対策

PHPSPOT 開発日誌で紹介されていた RSS 出力ライブラリの PHP Universal Feed Generator ですが、そのまま使用すると日本語のタイトルが文字化けして、XML として well-formed になりません。

これは、タイトルの出力部分で htmlentities 関数が使用されているためです。

FeedWriter.php 298行目

<?php
{
	$nodeText .= (in_array($tagName, $this->CDATAEncoding))? $tagContent : htmlentities($tagContent);
}           
?>

日本語の RSS を出力する場合は、htmlentities の第3引数で文字コードを指定します。

<?php
{
	$nodeText .= (in_array($tagName, $this->CDATAEncoding))? $tagContent : htmlentities($tagContent, ENT_QUOTES, 'UTF-8' );
}           
?>

PHP: htmlentities - Manual