My Location

Mar 19, 2009

JavaScript to convert HTML character entity references

To convert all numerical character entities in a string to their character equivalents you can do this:

str.replace(/&#(\d+);/g, function (m, n) { return String.fromCharCode(n); })

No comments:

Post a Comment