Tuesday, May 10, 2011

Full ASCII & HTML Codes Chart

HT FlowerPoop (really, that's his nick)

Recently I had to use some HTML, PHP, & JavaScript code that mixed both single- and double-quotes (' and "). The problem was that I had to display names that at times would include both single- and double-quotes that were escaped (\' and \"), which was causing premature closure of HTML tag attributes, so what to do?

htmlentitites() didn't work
stripslashes didn't work
I wasn't allowed to replace a single quote with a backtick (`)

FlowerPoop found that ' is the ASCII representation of single quote. str_replace("'","'",) did the trick!