Hey guys I am working on a custom RSS to retrieve data from a MySQL database and I've run into a little problem with regards to encoding. My content has characters like "£" which confuses everything! I got the feed to display everything as it should except for  which shows up at the start. The start of my code is: <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" > <?php header('Content-type: text/xml;charset=ISO-8859-1'); putenv("TZ=Europe/London"); ?> <channel> <title>Feed Title</title> <description>Feed Desc</description> PHP: Any ideas what this problem is caused by?
Firstly you should do any header stuff right at the beginning before anything is sent to the browser <?php header('Content-type: text/xml;charset=ISO-8859-1'); putenv("TZ=Europe/London"); ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" > <channel> <title>Feed Title</title> <description>Feed Desc</description> PHP: Secondly you could probably try this <?php header('Content-type: text/xml;charset=ISO-8859-1'); putenv("TZ=Europe/London"); ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" > <channel> <title><![CDATA[Feed Title]]></title> <description><![CDATA[Feed Desc]]></description> PHP:
try this one http://stackoverflow.com/questions/3255993/how-do-i-remove-i-from-the-beginning-of-a-file
Its a charset encoding issue. UTF-8 and ISO-8859-1 Having ISO-8859-1 makes the £ show up properly while having UTF-8 removes the  from the start
Someone set you up the BOM. Your editor is set to save as UTF-8 with the Byte Order Mark -- which is what's causing that problem. Load in all your files, and save without the BOM, and you'll be fine. Assuming whatever editor you are using has that option -- the good ones, and many of the crappy ones, do. http://en.wikipedia.org/wiki/Byte_order_mark The problem exists, as the link plussy pointed to, ENTIRELY because of whatever editor you are using. Of course, since you're saving the document as UTF-8, it's wrong to be using the iso-8859-1 encoding in the header either. You have to match formats when saving; which to be frank, you don't seem to be doing. You say that in the header, you have to say that in the editor. Funny nobody has asked the obvious question -- just what editor are you using? ... and the other obvious question, this is 2012 not 1997, why are you trying to use ISO-8859?