Question: I'm writing some RSS feeds in PHP and stuggling with character-encoding issues. Should I utf8\_encode() before or after htmlentities() encoding? For example, I've got both ampersands and Chinese characters in a description element, and I'm not sure which of these is proper:

```
$output = utf8_encode(htmlentities($source)); or
$output = htmlentities(utf8_encode($source));

```

And why?

Answer: 
Don't use `htmlentities()`! 

Simply use UTF-8 characters. Just make sure you declare encoding of the feed in HTTP headers (`Content-Type:application/xml;charset=UTF-8`) or failing that, in the feed itself using `<?xml version="1.0" encoding="UTF-8"?>` on the first line.
It might be easier to forget htmlentities and use a CDATA section. It works for the title section, which doesn't seem support encoded HTML characters in Firefox's RSS viewer:

```
<title><![CDATA[News & Updates  " > » ☂ ☺ ☹ ☃  Test!]]></title>

```