GreyWyvern.com

htmlentities() bites the dust

Feb 10, 2004

I've used the PHP function htmlentities() for years, making my text safe to print to the screen and still remain XHTML Strict.

Well, all that changed today when I discovered the not only does htmlentities() make a string safe to print, it also translates UTF-8 encoded characters into so much gibberish.

So instead of htmlentities(), I now use htmlspecialchars() which only translates a select few characters. And looking back, unless there's a really, really, really good reason, you should always be using htmlspecialchars()

I learn something new every day :/

Orca Script Rebuild Why you shouldn't use CSS selector bugs

Comments closed

Recent posts

  1. Iguana no Musume / Iguana Girl Aug 2016
  2. What I'd Like To See In The Elder Scrolls VI - Part 2 Aug 2015
  3. What I'd Like To See In The Elder Scrolls VI Jul 2015
  4. Cyprus, and what capitalists want Mar 2013
  5. Let interest rates on housing rise Sep 2012
  6. Archive

Items of Interest

Webcomics Reading List

Good Eats

Twitter RSS 2.0 Valid XHTML 1.0! Copyright © 2017 Brian Huisman AKA GreyWyvern
ContactSite mapSearch