JSFiddle - React, Tailwind, and code Playground

HTML

<h1>Encode/Decode 400 ASCII chars in a tweet</h1>
<pre>
// Encoder
window.e=function(source,i,tmp,result){
  tmp = "";
  result = "";
  for(i in source){
    tmp += (0+source.charCodeAt(i).toString(2)).slice(-7);
  }
  for(i = 0; tmp; tmp = tmp.slice(10)){
    result += String.fromCharCode((i++ % 2 ? 0xDC00 : 0xD800) + parseInt(tmp.substring(0, 10), 2));
  }
  return result;
}

// Decoder
window.d=function(source,i,tmp,result){
  tmp = "";
  result = "";
  for(i = 0; i < 400; ){
    tmp = tmp.slice(7) + source.charCodeAt(i++).toString(2).slice(-10);
    result += String.fromCharCode(parseInt(tmp.substring(0, 7), 2));
  }
  return result;
}

JavaScript

// encoder (140 chars)
eval(unescape(escape("𩐽𩡵𫡣𭁩𫱮𚁥𛁣𛁢𛁤𚑻𩀽𨠽𘠢𞱦𫱲𚁣𘁩𫠠𩐩𨠫🐨𜀫𩐮𨱨𨑲𠱯𩁥𠑴𚁣𚐮𭁯𤱴𬡩𫡧𚀲𚐩𛡳𫁩𨱥𚀭𝰩𞱦𫱲𚁣🐰𞱢𞱢👢𛡳𫁩𨱥𚀱𜀩𚑤𚰽𤱴𬡩𫡧𛡦𬡯𫑃𪁡𬡃𫱤𩐨𚁣𚰫𙐲🰵𝠳𜠰𞠵𝐲𞐶𚐫𬁡𬡳𩑉𫡴𚁢𛡳𭑢𬱴𬡩𫡧𚀰𛀱𜀩𛀲𚐩𞱲𩑴𭑲𫠠𩁽").replace(/uD./g,'')))

// Decoder (124 chars)
eval(unescape(escape("𩀽𩡵𫡣𭁩𫱮𚁥𛁤𛁢𛁣𚑻𨰽𨠽𘠢𞱦𫱲𚁤🐰𞰴𜀰🡤𞰩𨠽𨠮𬱬𪑣𩐨𝰩𚱥𛡣𪁡𬡃𫱤𩑁𭀨𩀫𚰩𛡴𫱓𭁲𪑮𩰨𜠩𛡳𫁩𨱥𚀭𜐰𚐬𨰫👓𭁲𪑮𩰮𩡲𫱭𠱨𨑲𠱯𩁥𚁰𨑲𬱥𢑮𭀨𨠮𬱵𨡳𭁲𪑮𩰨𜀬𝰩𛀲𚐩𞱲𩑴𭑲𫠠𨱽").replace(/uD./g,'')))


// Test
str='use Curses;for(@w=0..1920;@m=(-1,clear,80,-80,1);$l[$v]=2){addch$_^$p?("#",".",">",0,B)[$l[$_]]:"@"for@w;$p=$z if$l[$z=$p+$m[ord(getch)-104]]&3;$l[$z]%=3;if($l[$p]&2){@l=0*initscr;map{($_%80-$n%80)**2+abs($_-$n)/80<6?$l[$_]=rand 99<2?4%~($p=$_):1:0for@w,$n=$p+$n%4}0..99;1until$l[$v=rand@w]&$l[$p=rand@w]}$l[$_]&4?$l[$l[$n]==1&&$n^$p?$n:$_]=9|($n=$_+$m[rand 4+($l[$_]=1)]):0for@w;map$_=$_>3?4:$_,@l} '; // => 400 chars

console.log(e(str)); // => 140 chars

console.log(d(e(str))); // => 400 chars (same as str)