title: Convert UTF-8 data into the proper string format
body: <p>If I receive a UTF-8 string via a socket (or for that matter via any external source) I would like to get it as a properly parsed string object. The following code shows what I mean</p>
  
  <pre><code>var str='21\r\nJust a demo string \xC3\xA4\xC3\xA8-should not be anymore parsed';
  
  // Find CRLF
  var i=str.indexOf('\r\n');
  
  // Parse size up until CRLF
  var x=parseInt(str.slice(0, i));
  
  // Read size bytes
  var s=str.substr(i+2, x)
  
  console.log(s);
  </code></pre>
  
  <p>This code should print</p>
  
  <blockquote>
    <p>Just a demo string äè</p>
  </blockquote>
  
  <p>but as the UTF-8 data is not properly parsed it only parses it up to the first Unicode character</p>
  
  <blockquote>
    <p>Just a demo string Ã¤</p>
  </blockquote>
  
  <p>Would anyone have an idea how to convert this properly?</p>