Skip to content

Instantly share code, notes, and snippets.

@xorgy
xorgy / comeonman.js
Last active January 13, 2017 01:35 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
function decodeHtmlEntity(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
function encodeHtmlEntity(str) {
var buf = '';
for (var i = 0; i < str.length; i++) {