Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created April 29, 2015 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JavaScript-Packer/10edde0c6344955d1ed3 to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/10edde0c6344955d1ed3 to your computer and use it in GitHub Desktop.
Escape all characters to HTML entities (codepoints)
function escapeHTML(Δ){
return Δ.replace(/./g, function(e){
return "&#"+e.charCodeAt(0)+";";
});
};
alert(escapeHTML("JavaScript Packer"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment