“the j stands for Jack”
about me | blog | facebook profile | linkedin profile | twitter profile | stuff i've done | stuff i like | wordpress plugins

26 February, 2010

How to unescape HTML entities in JavaScript

Filed under: Useful,Web Development — Tags: , , — John @ 10:44 pm

This is one of those routine web development things which you assume is inbuilt, but actually proves quite tedious to find a nice solution to.

Specifically, I am talking about converting something like ' to ‘ or & to & directly in Javscript.
This function does exactly that! Note how it adds a function to the prototype for String, so is called in the following way:

"Hello José".unescapeHtml()

Find the code here: paul schreiber » Blog Archive » JavaScript: how to unescape HTML entities.

Powered by WordPress