code: function toHtmlEntities(str) {
          str = str || '';
          return str.replace(/./gm, function(s) {
              return "&#" + s.charCodeAt(0) + ";";
          });
      }
docs: Convert html tags to html entites
  @param str
  @returns {XML|string|*|void}