JSFiddle - React, Tailwind, and code Playground

by mhctoledo

HTML

<p>
prueba: &#254;
</p>

<p>
prueba: &#643;
</p>

<p>
prueba: &#373;
</p>

<p>
prueba: &#7811;
</p>

<p>
prueba: &#58;  &#720;
</p>

<p>
prueba: &#104;
<br>
prueba: <sup>h</sup>
</p>

JavaScript

var a = "h";
//document.write(a.charCodeAt(0));
//document.write("<p>&254;</p>");

function convertToAscii(str) {
  var result = '';
  var currentChar = '';
  var i = 0;
  for (; i < str.length; i += 1) {
    currentChar = str[i].charCodeAt(0).toString(2);
    if (currentChar.length < 8) {
      while (8 - currentChar.length) {
        currentChar = '0' + currentChar;
      }
    }
    result += currentChar;
  }
  return result;
}

//document.write(a.codePointAt());