views:

67

answers:

2

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
+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
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
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