JSFiddle - React, Tailwind, and code Playground

by dshilkret

JavaScript

if (!("TextEncoder" in window)) 
  alert("Sorry, this browser does not support TextEncoder...");

var enc = new TextEncoder(); // always utf-8
console.log(enc.encode("This is a string converted to a Uint8Array"));
var myUint8 = new U
console.log(ab2str(enc.encode("this is a string converted to a uint8Array")));
function ab2str(buf) {
  return String.fromCharCode.apply(null, new Uint16Array(buf));
}