title: Unicode composition in javascript
body: <p>I am looking for a way to count ligatures as single units as they are displayed to user, e.g. <a href="https://www.compart.com/en/unicode/U+FEFB" rel="nofollow noreferrer">https://www.compart.com/en/unicode/U+FEFB</a>. </p>
  
  <p>When this character is typed (type G on Arabic keyboard), it's inserted in decomposition form, i.e. <code>U+0644 U+0627</code>. </p>
  
  <p>I'm able to decompose <code>U+FEFB</code> by</p>
  
  <pre><code>escape(String.fromCodePoint(0xFEFB).normalize("NFKD")) // '%u0644%u0627'
  </code></pre>
  
  <p>Is there a way to compose <code>U+0644 U+0627</code> into <code>0xFEFB</code>?</p>
  
  <p>Why this does work?</p>
  
  <pre><code>escape(String.fromCodePoint(0x0644, 0x0627).normalize("NFKC"))
  </code></pre>
  
  <p>The only idea I has was to iterate over unicode ranges I'm interested in, decompose and create a map, but I'm hoping there's a better way.</p>