views:

22

answers:

3

When I fetch data from a feed I store it in a table, the problem is that the format of the quote, so It will store instead of ' (I hope you can see the difference)

You get the same thing when you copy paste code from a website or word document in your editor.

the problem is that when I display the content on my site I get the following, how to I get rid of that?

alt text

A: 

Echo the text like this on your page:

echo  htmlentities($your_text_here);
Sarfraz
+2  A: 

The problem relates to character sets. You need to find out what the character set of the feed is (how it's encoded) and also how your site is encoded too.

If the feed will never contain HTML markup then you can use htmlentities() otherwise you'll need to do conversion of the feed at input so that it matches up with the same charset as your site.

MySQL has good internationalization support too and would be able to perform this conversion.

Without knowning the specifics of your site it's hard to advise further

James C
should I use htmlentities before I store it into the database. I have the format of the database set to utf8_unicode (or utf8_general)
krike
A: 

James C already has the correct answer.

If your site is ISO-8859-1 encoded, and you are using the results of a UTF-8 encoded feed. In that case, a

utf8_decode($text);

would be a quick trick to make it work. On the long run, it would be good to switch to UTF-8 altogether.

If you're outputting data from your database, you need to check the encoding of your

  • database tables
  • the mySQL connection
  • your page encoding

For more sophisticated character set conversion, there is iconv().

Excellent basic reading on the issue is The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Pekka
I was allready using iconv() for the title --> $title = iconv("UTF-8", "ISO-8859-1//TRANSLIT",$item->get_title());I'll have a closer look into this.
krike