title: how to deal with special characters in nodejs fs readdir function
body: <p>I'm reading a directory in nodejs using the <code>fs.readdir()</code> function. You feed it a string containing a path and it returns an array containing all the files inside that directory path in string format. It does not work for me with special characters (like <code>ï</code>).</p>
  
  <p><em>I came across <a href="https://stackoverflow.com/questions/7738430/special-characters-in-node-js-readdir">this similar issue</a>, however I am on OS X).</em></p>
  
  <p>First I created a new dir called <code>encoding</code> and created a file called <code>maïs.md</code> (with my editor Sublime Text).</p>
  
  <pre><code>fs.readdir('encoding', function(err, files) {
    console.log(files);                                   // [ 'maïs.md' ]
    console.log(files[0]);                                // maïs.md
    console.log(files[0] === 'maïs.md');                  // false
    console.log(files[0] == 'maïs.md');                   // false
    console.log(files[0].toString('utf8') === 'maïs.md'); // false
  });
  </code></pre>
  
  <p>The above test works correctly for files without special characters. How can I compare this correctly?</p>