Solved

cannot replace ? with £ in external RSS feed

Posted on 2007-04-03
4
238 Views
Last Modified: 2008-02-26
ive got a RSS feed displaying on the frontpage of this site:

http://www.quest-recruiting.com/

notice that the £ signs show as ? .  im using magpie rss feed scripts and they work well except i cant seem to get the ? replaced with a £ or £!!  I have tried everything:

$url = 'http://business.scotsman.com/topics.cfm?format=rss&tid=181';
$rss = fetch_rss($url);
$limit = rand(0,count($rss->items));

foreach($rss->items as $item)
{
      $rss_description = $item['description'];
      $rss_title = $item['title'];
      
      /*
      $rss_title = str_replace('‘',''',$rss_title);                  
      $rss_title = str_replace('’',''',$rss_title);                
      $rss_title = str_replace('‚',',',$rss_title);                
      $rss_title = str_replace('“','"',$rss_title);                
      $rss_title = str_replace('”','"',$rss_title);                
      $rss_title = str_replace('"','"',$rss_title);                                           
      $rss_title = str_replace('¼','¼',$rss_title);                     
      $rss_title = str_replace('½','½',$rss_title);        
      $rss_title = str_replace('¾','¾',$rss_title);
      $rss_title = str_replace("'","'",$rss_title);
      $rss_title = str_replace('—','-',$rss_title);
      $rss_title = str_replace(' — ',' - ',$rss_title);
      $rss_title = str_replace('  ',' ',$rss_title);
      $rss_title = str_replace('£','£',$rss_title);
      */
      
      $rss_title = str_replace('?','£',$rss_title);
      
      $rss_description = removeEvilTags($rss_description);
      
      /*
      $rss_description = str_replace('‘',''',$rss_description);                  
      $rss_description = str_replace('’',''',$rss_description);                
      $rss_description = str_replace('‚',',',$rss_description);                
      $rss_description = str_replace('“','"',$rss_description);                
      $rss_description = str_replace('”','"',$rss_description);                
      $rss_description = str_replace('"','"',$rss_description);                                           
      $rss_description = str_replace('¼','¼',$rss_description);                     
      $rss_description = str_replace('½','½',$rss_description);        
      $rss_description = str_replace('¾','¾',$rss_description);
      $rss_description = str_replace("'","'",$rss_description);
      $rss_description = str_replace('—','-',$rss_description);
      $rss_description = str_replace(' — ',' - ',$rss_description);
      $rss_description = str_replace('  ',' ',$rss_description);
      $rss_description = str_replace('£','£',$rss_description);
      */
      
      $rss_description = str_replace('?','£',$rss_description);
      
      $s_HtmlContent .= '<h3 class="news_feeds"><a href="'.$item['link'].'" title="'.$rss_title.'" onclick="javascript:window.open(this.href);return false;">'.$rss_title.'</a></h3>'."\n";
      $s_HtmlContent .= '<p class="news_feeds">'.nl2br($rss_description).'</p>'."\n";
      
      if(--$limit < 1)
      {
            break;
      }
}

the removeEvilTags() function just remove <img> tags and other tags that i dont want...

please help.
0
Comment
Question by:ellandrd
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
richswyatt earned 500 total points
ID: 18842744
I would try using the html_entities or html_special_chars function on $rss_description PRIOR to the str_replaces.

This will ensure that the symbol is in a format that can be 'found' in the str_replace. I've run into this before and that was the solution.

~Rich
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18842769
i will give it a try. if it works i will kick myself as i never though of trying these functions....
0
 
LVL 16

Author Comment

by:ellandrd
ID: 18842874
htmlentities() worked!

thank you so much!
0
 
LVL 5

Expert Comment

by:richswyatt
ID: 18842879
You're welcome. The little things always get us. :-)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question