I'm using a simple php script to scour an RSS feed, store the scoured data to a temporary cache flat file, then display it along the side of my website. However all the characters with accents appear as "�" What is causing this and how can I fix it? Thank you!
A:
It seems a conflict in the codification. All the files should have the same codification (like UTF-8) and must be served on it.
Tae
2010-10-16 16:32:13
+3
A:
You're having a problem with your character encoding. Depending on which encoding the feed uses, you have to use the same to display your data, or try to convert it to the encoding you're using on your website. PHP offers iconv() for that purpose, for example.
In case the encoding is UTF-8 (or any other multibyte encoding), you also have to make sure you use multibyte-safe functions/methods in your PHP scripts, in case you process the feed in your application.
To deliver your content in UTF-8, for example, you have to send the appropriate content header before any other output.
Example:
header('Content-Type: text/html; charset=utf-8');
Thomas
2010-10-16 16:34:35
Just to state the obvious: EVERYONE should EVERYWHERE (websites, feeds, databases, ...) use the UFT-8 charset these days. Other charsets should only be used to work with legacy data / apps.And a small hint: To find out which charset is used, you can usually open the site and change the charsets in your browser until the questionmarks are replaced by the real symbols.
b_i_d
2010-10-16 17:17:25
Couldn't agree more. ;) In the real world, there's still tons of non utf-8 applications/web sites, though. And it's always a nightmare.
Thomas
2010-10-16 17:35:30