我正在使用 PHP 生成一个 RSS 提要,其中包含位于服务器上存储的文件中的描述文本。问题是,文件都编码不同,一些UTF-8,us-ascii等。有什么好的方法来统一每个描述的编码?
我已经尝试过了,但我仍然在 XML 文件中遇到错误。
这是错误 我的代码
<channel>
<?php
mysql_connect(xxx);
mysql_select_db(xxx);
$result = mysql_query("SELECT * FROM articles");
while ($row = mysql_fetch_array($result)) {
echo "<item>";
echo "<description>";
echo file_get_contents($row['location']);
echo "</description>";
#The location to the file containing the article is in the DB, clearly.
echo "<title>";
echo $row['title'];
echo "</title>";
echo "<link>";
echo "[link to entry goes here...]";
echo "</link>";
#Echo some more RSS tags that I don't need to specify in this example.
echo "</item>";
?>
</channel>