所以我有一个小的PHP脚本,可以为我的博客的rss源生成xml感觉.但是,它会引发此错误:
This page contains the following errors:
error on line 23 at column 14: Encoding error
Below is a rendering of the page up to the first error.
(见此处:http://aviatex14.co.uk/rss.xml)
这是生成它的代码:
while ($line = mysql_fetch_array($result)) {
$return[] = $line;
var_dump(date("Y-m-d H:i:s", $line['timestamp']));
}
$now = date("D, d M Y H:i:s T");
$output = "<?xml version=\"1.0\" encoding=\"UTF-16\" ?>
<rss version=\"2.0\">
<channel>
<title></title>
<link></link>
<description></description>
<pubDate></pubDate>
<language>en-us</language>
<lastBuildDate>$now</lastBuildDate>
";
foreach ($return as $line) {
$output .= "<item><title>".htmlentities($line['title'])."</title>
<link>http://blog.aviatex14.co.uk/permalink.php?uid=".htmlentities($line['uid'])."</link>
<description>".htmlentities(strip_tags($line['entry']))."</description>
<pubDate>".$date = date("Y-m-d H:i:s T", $line['timestamp'])."</pubDate>
</item>";
}
$output .= "</channel></rss>";
print "Content-Type: application/rss+xml";
echo $output;
$f = fopen("rss.xml", "w");
fwrite($f, $output);
fclose($f);
任何帮助,将不胜感激! :d
解决方法:
它在那条线上说“TOKYO A Japanese”(并且在饲料中也是如此). 不是utf-8.尝试utf8_encode
(或iconv
,如果你想要一个不同的编码)内容甚至更好:use an XML processor创建提要.