html entities

by devdev

HTML

<b>grassetto (interpretato)</b>

<br>

&lt;b&gt;grassetto (non interpretato, codifica manuale)&lt;/b&gt;

<br>

<script>
    var testo='<b>grassetto (not interpretato, codifica mediante script)</b>';
    var encodeHtmlEntity = function(str) {
  var buf = [];
  for (var i=str.length-1;i>=0;i--) {
    buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
  }
  return buf.join('');
};
    document.write(encodeHtmlEntity(testo));
</script>

<br>
    
<a href="http://www.w3schools.com/html/html_entities.asp">
http://www.w3schools.com/html/html_entities.asp
</a>