title: How to count the correct length of a string with emojis in javascript?
body: <p>I've a little problem.</p>
  
  <p>I'm using NodeJS as backend. Now, an user has a field "biography", where the user can write something about himself.</p>
  
  <p>Suppose that this field has 220 maxlength, and suppose this as input:</p>
  
  <pre><code>‍♀️‍♀️‍♀️‍♀️‍♀️‍♀️‍⚕️‍⚕️‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍ 
  </code></pre>
  
  <p>As you can see there aren't 220 emojis (there are 37 emojis), but if I do in my nodejs server</p>
  
  <pre><code>console.log(bio.length)
  </code></pre>
  
  <p>where bio is the input text, I got 221. How could I "parse" the string input to get the correct length? Is it a problem about unicode?</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p>I used this library: <a href="https://github.com/orling/grapheme-splitter" rel="noreferrer">https://github.com/orling/grapheme-splitter</a> </p>
  
  <p>I tried that:</p>
  
  <pre><code>var Grapheme = require('grapheme-splitter');
  var splitter = new Grapheme();
  console.log(splitter.splitGraphemes(bio).length);
  </code></pre>
  
  <p>and the length is 37. It works very well!</p>