This is just a quick sample of how to accomplish embedded HTML entity decryption with javascript. It's actually only a small portion of the code at the Scumple I wrote several years ago, but it was necessary for another project I am working on, so I dedicated this page to demontrating that functionality.
Back to the point. The code here converts entity encoded values like &0032; to their actual text counterparts, and place results into the box below. To start, just paste or enter some entity-encoded text within the box below. Then click Decode Text.
Results will appear here.
<script type="text/javascript"> function decodetest(){ //get the input var t = document.getElementById('dectest').value; //remove carriage returns t = t.replace(new RegExp("\\=\r\n","gim"), ""); //replace urlencoded values t = unescape(t); //replacement values var thechrs = new Array( ' ','!','"','#','$','%','&',"'",'(',')','*','+',',','-','.','/','0','1','2','3', '4','5','6','7','8','9',':',';','<','=','>','?','@','A','B','C','D','E','F','G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[', '\\',']','^','_','`','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o', 'p','q','r','s','t','u','v','w','x','y','z','{','|','}','~',' ','c','u','e','a', 'a','a','a','c','e','e','e','i','i','i','a','a','e','ae','ae','o','o','o','u','u', 'y','u','u','o','l','0','x','f','a','i','o','u','n','n','*','O','?','r','_','?', '?','!','<','>','_','_','_','|','|','a','a','a','c','|','|','+','+','c','y','+', '+','-','-','+','-','+','a','a','+','+','-','-','|','-','+','.','.','d','e','e', 'e','i','i','i','i','+','+','_','_','|','i','_','o','o','o','o','o','o','u','p', 'p','u','u','u','y','y','_',"'",'-','?','_','?','?','S','÷','¸','°','¨','·','¹', '³','²','_',' '); //replace js numeric array values var l = 32; for (l = 32; l < 256; l++){ t = t.replace(new RegExp("\\[" + l + ",","gim"),"[" + thechrs[l-32] + ","); t = t.replace(new RegExp("\\[" + l + ",","gim"),"[" + thechrs[l-32] + ","); } for (l = 32; l < 256; l++){ t = t.replace(new RegExp("," + l + "\\]","gim"),"," + thechrs[l-32] + "]"); t = t.replace(new RegExp("," + l + "\\]","gim"),"," + thechrs[l-32] + "]"); } for (l = 32; l < 256; l++){ t = t.replace(new RegExp("," + l + ",","gim"),"," + thechrs[l-32] + ","); t = t.replace(new RegExp("," + l + ",","gim"),"," + thechrs[l-32] + ","); } ta = t; t = t.replace(new RegExp("(\\[[^\\]]+)\\,([^\\]]+\\])","gim"), "$1$2"); while(ta !== t){ ta = t; t = t.replace(new RegExp("(\\[[^\\]]+)\\,([^\\]]+\\])","gim"), "$1$2"); } //replace entities var l = 32; for (l = 32; l < 100; l++){ t = t.replace(new RegExp("&#" + l + ";","gim"),thechrs[l-32]); t = t.replace(new RegExp("�" + l + ";","gim"),thechrs[l-32]); t = t.replace(new RegExp("�" + l + ";","gim"),thechrs[l-32]); } var l = 100; for (l = 100; l < 256; l++){ t = t.replace(new RegExp("&#" + l + ";","gim"),thechrs[l-32]); t = t.replace(new RegExp("�" + l + ";","gim"),thechrs[l-32]); } //return results document.getElementById("parsed").innerHTML = t; } </script>