SimplePie (v1.3.1) を使用して、Web ページに RSS フィードを表示しています。タイトルの 1 つにユーロ (€) 記号が含まれており、ページ上では â と表示されます。SimplePie のウェブサイトでデモを使用すると、正しく表示されるので問題ありません。しかし、私はそれを機能させることができません。
私がすでにしたこと:
- SimplePie の Web サイトとドキュメントで検索する
 - stackoverflow の Web サイトで検索
 - Google で検索
 - 与えられた「解決策」を何十回も試しましたが、運がありませんでした
 
私が見つけたのは、おそらく文字エンコーディングの問題であり、私が知る限り、これは UTF-8 に設定する必要があるということです。Beneith は、SimplePie デモに基づいた現在のテスト コードです。SimplePie の FAQ で指定された 3 つの解決策を既に追加しました (「I'm seen strange characters 」を参照してください)。
私は何を間違っていますか?
<?php
header('Content-type:text/html; charset=utf-8');
// Make sure SimplePie is included. You may need to change this to match the location of autoloader.php
// For 1.3+:
require_once('./php/autoloader.php');
// We'll process this feed with all of the default options.
$feed = new SimplePie();
// Set the feed to process.
$feed->set_feed_url(***RSS_FEED_URL_HERE***);
// Run SimplePie.
$feed->init();
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();
// Let's begin our XHTML webpage code.  The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag.
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
    <title>Sample SimplePie Page</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <style type="text/css">
    /*some css*/
    </style>
</head>
<body>
    <div class="header">
        <h1><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1>
        <p><?php echo $feed->get_description(); ?></p>
    </div>
    <?php
    foreach ($feed->get_items() as $item):
    ?>
        <div class="item">
            <h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
            <p><?php echo $item->get_description(); ?></p>
            <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
        </div>
    <?php endforeach; ?>
</body>
</html>
[編集] 詳細情報:
- RSS からの XML は UTF-8 でエンコードされています ( 
<?xml version="1.0" encoding="UTF-8"?>) - 使用
echo str_replace("€", "€", $item->get_title());は機能しますが、あまり良くありません