0

I have created Feed section in my site in which i am pulling data from a worpress blog , the issue i am facing is that when i access the data then at some point it shows garbage values such as   , – . Kindly let me know how can i modify my following code so it'll get the data as it is from the blog.

As an example:

Right (On blog): Peace of mind during holiday travels especially for seniors in your lives

Wrong (On feed):Peace of mind during holiday travels – especially for seniors in your lives

soft genic
  • 2,016
  • 3
  • 27
  • 44

2 Answers2

1

Looks like a difference in encoding between the feed and you. You could try converting it to UTF-8 using the following:

$utf8_content = mb_convert_encoding($content, 'UTF-8', mb_detect_encoding($content));

Also double check your browser is set to UTF-8 as well.

Adam Westbrook
  • 1,041
  • 9
  • 13
  • Thanks, I used this to reolve my issue `htmlentities($entry->title, ENT_QUOTES | ENT_IGNORE, 'UTF-8')` just one problem this code is messing up the url else it'll handle the garbage values, kindly let me know how can i ignore the url for the code mentioned above – soft genic Feb 14 '13 at 17:54
  • Using `htmlentities()` on a url probably isn't a good idea, try `urlencode()` [link](http://php.net/manual/en/function.urlencode.php) – Adam Westbrook Feb 19 '13 at 10:35
0

Following line of code fixed the garbage values issue for me :

$ret = $feed;     
echo htmlspecialchars_decode(htmlentities($ret, ENT_QUOTES | ENT_IGNORE, 'UTF-8')); 
soft genic
  • 2,016
  • 3
  • 27
  • 44