JSFiddle - React, Tailwind, and code Playground

by ischenkodv

HTML

encodeURIComponent
<pre id="p1"></pre><br />

escape
<pre id="p2"></pre><br />


<pre id="p3"></pre>

encode_utf8(x) == unescape(encodeURIComponent(x))
<pre id="p4"></pre><br />

iframe<br />
<iframe id="i"></iframe>

JavaScript

function encode_utf8( s )
    {
      return unescape( encodeURIComponent( s ) );
    }

    function decode_utf8( s )
    {
      return decodeURIComponent( escape( s ) );
    }

var html = "<!DOCTYPE html><html><head>    <meta charset=utf-8 />    <title>Some Page</title>    </head><body><h1>Some Page</h1>"+
    "<p>So… What’s up, Doc‽</p>"+
    "</body></html>";

$('#p1').text(encodeURIComponent(html));
$('#p2').text(escape(html));
//$('#p3').text(encode_utf8(html));
$('#p4').text(encode_utf8(html));


$('#i').attr('src', 'data:text/html;charset=utf-8;base64,'+window.btoa(encode_utf8(html)));