Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris O'Donnell codfish

View GitHub Profile
@codfish
codfish / htmlentity.js
Created Feb 28, 2018 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
View htmlentity.js
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
You can’t perform that action at this time.