title: What is the correct method for calculating the Content-length header in node.js
body: <p>I'm not at all sure whether my current method of calculating the content-length is correct. What are the implications of using string.length() to calculate the content-length. Does setting the charset to utf-8 even mean anything when using node.js?</p>
  
  <pre><code>payload = JSON.stringify( payload );
  
  response.header( 'content-type', application/json; charset=utf-8 );
  response.header( 'content-length', payload.length );
  
  response.end( payload );
  </code></pre>