Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
@jdalton

This comment has been minimized.

Copy link

commented Sep 14, 2010

Doesn't handle quotes but can handle many more entities...
http://github.com/jdalton/fusejs/blob/master/src/lang/html.js#L51-131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.