Wordpress feeds showing crazy characters

MTT

Aspirant
Joined
Dec 28, 2017
Messages
26
My Wordpress blog use the charset UTF-8 and when I try to display the feed through a RSS feed reader on my VBulletin forum (that is encoded with ISO-8859-1), the output show weird characters like: †etc. I tried to put this code: header('Content-Type: text/html; charset=VALUE'); in my feed_reader.php and fix the problem, I can see the feeds correctly but now all the vBulletin shows that crazy characters.

How can I fix this?

This is my feed_reader.php by the way:

PHP:
<?php

 $url = "FEED URL";
 if(isset($_POST['submit'])){
   if($_POST['feedurl'] != ''){
     $url = $_POST['feedurl'];
   }
 }

 $invalidurl = false;
 if(@simplexml_load_file($url)){
  $feeds = simplexml_load_file($url);
 }else{
  $invalidurl = true;
  echo "<h2>Invalid RSS feed URL.</h2>";
 }


 $i=0;
 if(!empty($feeds)){

  $site = $feeds->channel->title;
  $sitelink = $feeds->channel->link;


  foreach ($feeds->channel->item as $item) {

   $title = $item->title;
   $title = substr($title, 0, 32)."";
   $link = $item->link;
   $description = $item->description;
   $postDate = $item->pubDate;
   $pubDate = date('D, d M Y',strtotime($postDate));




   if($i>=3) break;
  ?>
   <div class="post">
     <div class="post-head2">
       <h2 class="news_feed2"><a class="feed_title" href="<?php echo $link; ?>"><?php echo $title; ?></a></h2>

     </div>
     <div class="post-content2">
       <?php echo implode(' ', array_slice(explode(' ', $description), 0, 20)) . "..."; ?>
     </div>
   </div>

   <?php
    $i++;
   }
 }else{
   if(!$invalidurl){
     echo "<h2>No item found</h2>";
   }
 }
 ?>
</div>
 

MTT

Aspirant
Joined
Dec 28, 2017
Messages
26
I fixed it by adding this line: "utf8_decode( $item->title )"

Thanks :)
 
Top