title: Sanitize RSS Feed content for a Feed Aggregator
body: <p>I'm building a RSS feed aggregator/reader in PHP. Since RSS is essentially user generated content, I do not want to rely on the feed contents being safe.</p>
  
  <p>I'm looking for advice on sanitizing the feed contents for storage and display on user's devices. Currently, I'm using <code>htmlentities(feed_content)</code> to escape all characters but that does not work right since it UTF-8 encodes the characters which cannot be decoded back in Javascript (That I use for frontend construction).</p>
  
  <pre><code>- Original: "Soundtrack: Dinosaur Jr. - Don’t Pretend You Didn’t Know I hadn’t thought much..."
  
  - After htmlentities: "Copyright-Infringing Tweets Will Now Be &amp;amp;#8220;Withdrawn&amp;amp;#8221; Instead of &amp;amp;#8220;Disappeared..."
  
  - After JS decodeURI: "Copyright-Infringing Tweets Will Now Be &amp;amp;#8220;Withdrawn&amp;amp;#8221; Instead of &amp;amp;#8220;Disappeared..."
  </code></pre>
  
  <p>If I remove the htmlentities above, the text shows correctly. But I'm not sure if that is the right way to ensure the data is sanitized</p>