Jump to content

RSS and Character Set problems


Recommended Posts

I have created an RSS feed with a ISO-8859-1 character set but I am having issues with how its displayed.Two of the places the RSS feed is displayed in show a pound sign as £ whilst the third shows a square. They are all set to treat the RSS feed as ISO-8859-1.What is the correct way to write a £ in a ISO-8859-1 RSS feed, can it be written as £ or does it need encoding.

Link to post
Share on other sites

I'm assuming the RSS feed is a separate file?The way you can fix this is if you actually encode the file as UTF-8, not just specify the encoding in the prolog. To preserve the £, you can do the following:1. Create a new text file.2. Save the file as UTF-8. In Notepad, you can do that from the "Encoding" dropdown at the "Save As..." dialog.3. Open up your RSS feed with the same editor.4. Copy the RSS feed to the new file.5. Save the new file.6. Check the new file (just in case...), and if all is OK, replace the old file with the new file.

Link to post
Share on other sites

The file is partly created with PHP so I am already encoding some of the content with htmlspecialchars. I guess simply changing the charset in htmlspecialchars to UTF-8 would not be enough as this would not cover the £. Am I better using utf8_encode or should I use both and in what order.I think the problem with why the feed doesnt display correctly on of the sites that use it is that the site that uses it is displaying in UTF-8.

Link to post
Share on other sites

The file that generates the feed needs to be converted to UTF-8 per the procedure I described above.Then, you need to explicitly add a header that either assumes or explicitly states UTF-8 as an encoding, such as "application/xml" for example.Your XML prolog doesn't have to say UTF-8, but it may.Yes, htmlspecialchars() needs to use UTF-8 as its third argument as well.If you're gathering the data from MySQL, you need to ensure your connection is with UTF-8, using mysqli::set_charset() if you're using MySQLi (as you should anyway).And the table where the data is stored should itself also be in UTF-8. If that's not already the case, convertion of the database is a little harder, so you should take up the rest of this list before you venture there.

Link to post
Share on other sites

I have ended up running 2 feeds, one for the sites require ISO-8859-1 and one for the site requiring UTF-8. I have changed the headers to UTF-8 and run the data pulled from the database through htmlspecialchars() with UTF-8 and then through the utf8_encode() function which seems to have resolved the pound sign.Strangely when viewing the code it hasnt encode the pound sign (its still £) but it now displays correctly. If I take the utf8_encode out of the script it fails with the pund sign again depsite still being displayed as £ in the code.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...